diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6c12dcef..c5df2ff6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,6 +3,7 @@ on: branches: - main pull_request: {} + workflow_call: {} concurrency: group: '${{ github.workflow }} - ${{ github.head_ref || github.ref }}' @@ -14,7 +15,7 @@ permissions: jobs: - build: + check: strategy: matrix: node-version: [18, 20] @@ -31,8 +32,7 @@ jobs: node-version: ${{ matrix.node-version }} - name: Setup LCOV uses: hrishikesh-kadam/setup-lcov@v1 - - - name: Enable Yarn + - name: Setup Yarn run: corepack enable - name: Install Packages @@ -48,7 +48,7 @@ jobs: run: yarn coverage - name: Report Coverage - if: ${{ matrix.node-version == 20 }} + if: ${{ matrix.node-version == 20 && github.event_name == 'pull_request' }} uses: zgosalvez/github-actions-report-lcov@v4 with: coverage-files: coverage/lcov.info diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 00000000..1a3b4037 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,45 @@ +on: + workflow_dispatch: {} + release: + types: + - published + +jobs: + check: + uses: ./.github/workflows/ci.yml + secrets: inherit + + publish: + needs: check + + runs-on: ubuntu-latest + + permissions: + contents: read + id-token: write + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: lts/* + registry-url: 'https://registry.npmjs.com' + check-latest: true + - name: Setup Yarn + run: corepack enable + + - name: Install Packages + run: yarn install + + - name: Build + run: yarn build + + - name: Publish + run: | + npm install -g npm@latest + npm publish --provenance + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/package.json b/package.json index df322535..436181c6 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,7 @@ "lint-docs": "markdownlint-cli2 \"**/*.md\" \"#node_modules\"", "lint-eslint-docs": "yarn build && eslint-doc-generator --check", "docs": "eslint-doc-generator", - "release": "bumpp && yarn run build", + "release": "bumpp && echo \"Create a new release in GitHub to trigger the publish workflow.\"", "test": "vitest", "coverage": "vitest run --coverage", "typecheck": "tsc --noEmit"