From 2545f2d42bfddca706c6209d29d5b6b84e68ce29 Mon Sep 17 00:00:00 2001 From: Dennis Smolek Date: Tue, 24 Nov 2026 18:12:58 +0900 Subject: [PATCH] release.yml: publish via npm trusted publishing (OIDC) instead of NPM_TOKEN Drops the NPM_TOKEN secret; the npm CLI exchanges the workflow's OIDC token instead. Trusted publishing needs npm >= 11.5.1, so node 20 -> 24 plus an explicit npm upgrade step. Header comment now documents the one-time Trusted Publisher setup on npmjs.com. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/release.yml | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 92660ca0..937de55d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,14 +1,16 @@ name: Release (npm publish) # Manual, deliberate trigger: publishing IS the launch (it also retires the -# TFJS 0.x line as `latest`). Run from the Actions tab once NPM_TOKEN is set. +# TFJS 0.x line as `latest`). Run from the Actions tab. # -# Setup (one-time, repo admin): -# npmjs.com -> Access Tokens -> Generate granular token with read/write on -# the `denoiser` package -> add as repo secret NPM_TOKEN. +# Auth is npm trusted publishing (OIDC), no NPM_TOKEN secret. One-time setup +# by a `denoiser` package owner on npmjs.com: +# package -> Settings -> Trusted Publisher -> GitHub Actions +# Organization: pmndrs Repository: denoiser +# Workflow filename: release.yml Environment: (blank) # -# Publishes with npm provenance (links the tarball to this workflow run), -# which needs `id-token: write` and node >= 20 / npm >= 9.5. +# Trusted publishing needs `id-token: write` and npm >= 11.5.1 (node 24 ships +# npm 11). Provenance is attached automatically. on: workflow_dispatch: @@ -33,7 +35,7 @@ jobs: run: corepack enable - uses: actions/setup-node@v4 with: - node-version: '20' + node-version: '24' cache: 'yarn' registry-url: 'https://registry.npmjs.org' - name: Install @@ -46,8 +48,10 @@ jobs: run: yarn workspace denoiser exec tsc --noEmit - name: Show what will publish run: cd packages/denoiser && npm pack --dry-run - # npm (not yarn) so setup-node's registry-url + NODE_AUTH_TOKEN apply. + # Ensure the npm CLI supports trusted publishing even if the runner's + # bundled npm drifts. + - name: npm >= 11.5.1 + run: npm install -g npm@^11.5.1 && npm --version + # npm (not yarn): the OIDC token exchange is done by the npm CLI. - name: Publish run: cd packages/denoiser && npm publish --provenance --access public --tag "${{ inputs.tag }}" - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}