From 6b30a4c5077a4a2a3261bfed69c12446fe170bbc Mon Sep 17 00:00:00 2001 From: Marcis Bergmanis Date: Wed, 28 Oct 2026 18:19:28 +0200 Subject: [PATCH] Use npm trusted publishing for releases --- .github/workflows/publish.yml | 38 ++++++++++++++++++++++++++--------- 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index f1b2321..fd743e1 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -2,33 +2,53 @@ name: Publish on: release: - types: [created] + types: [published] + workflow_dispatch: + inputs: + tag: + description: Existing release tag to publish + required: true + type: string + +permissions: + contents: read jobs: test: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v1 + - uses: actions/checkout@v6 + with: + ref: ${{ inputs.tag || github.ref }} + - uses: actions/setup-node@v6 with: - node-version: 16 + node-version: 24 + package-manager-cache: false - run: npm ci - run: npm test - run: npm run lint publish-npm: needs: test + permissions: + contents: read + id-token: write runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v1 + - uses: actions/checkout@v6 + with: + ref: ${{ inputs.tag || github.ref }} + - uses: actions/setup-node@v6 with: - node-version: 16 + node-version: 24 + package-manager-cache: false registry-url: https://registry.npmjs.org/ - run: npm ci - run: npm run build - run: npm run declarations - run: npm run test:package - - run: npm publish + - name: Verify release version env: - NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} + RELEASE_TAG: ${{ inputs.tag || github.ref_name }} + run: node -e 'if (process.env.RELEASE_TAG !== "v" + require("./package.json").version) process.exit(1)' + - run: npm publish