From 74a21c2898c81a96f2e30ad9b59f1184629ce57f Mon Sep 17 00:00:00 2001 From: Jason Weinzierl Date: Tue, 26 Nov 2024 09:22:42 -0600 Subject: [PATCH 1/2] chore(ci): rename build job to check --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6c12dcef..7be1ce3f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,7 +14,7 @@ permissions: jobs: - build: + check: strategy: matrix: node-version: [18, 20] From bdf1c3e12fb30a450158ab7159ecf1174584999a Mon Sep 17 00:00:00 2001 From: Jason Weinzierl Date: Tue, 26 Nov 2024 10:12:13 -0600 Subject: [PATCH 2/2] chore(ci): set up publish workflow --- .github/workflows/ci.yml | 6 ++--- .github/workflows/publish.yml | 45 +++++++++++++++++++++++++++++++++++ package.json | 2 +- 3 files changed, 49 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7be1ce3f..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 }}' @@ -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"