Skip to content

ci: switch npm publish to OIDC trusted publishing - #4274

Merged
huozhi merged 3 commits into
mainfrom
oidc-trusted-publishing
Jun 22, 2026
Merged

huozhi merged 3 commits into
mainfrom
oidc-trusted-publishing

Conversation

@huozhi

@huozhi huozhi commented Jun 20, 2026

Copy link
Copy Markdown
Collaborator

The release pipeline currently authenticates npm publish with a long-lived NPM_TOKEN_ELEVATED secret. This moves it to npm's OIDC trusted publishing, which removes the need to store and rotate a publish token.

What changed

  • Removed the NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN_ELEVATED }} env from both publish steps in the release job — auth now flows through the existing id-token: write permission via OIDC.
  • Dropped the explicit --provenance flag, since provenance is generated automatically under trusted publishing.
  • Pinned npm to latest in the release job, as trusted publishing requires npm >= 11.5.1 (Node 24's bundled npm may be older).

Before merging

swr must be configured as a trusted publisher for this repo/workflow on npmjs.com (Package settings → Trusted Publisher), pointing at .github/workflows/test-release.yml. Once that's set, the NPM_TOKEN_ELEVATED secret can be deleted.

Remove the long-lived NPM_TOKEN_ELEVATED secret from the release job and
rely on npm's OIDC trusted publishing via the existing id-token: write
permission. Provenance is generated automatically under trusted publishing,
so the explicit --provenance flag is no longer needed. Pin npm to latest in
the release job since trusted publishing requires npm >= 11.5.1.

Co-authored-by: v0agent <[email protected]>
Corepack is already enabled by the install action, so use it to activate a
pinned npm version (11.5.1) for OIDC trusted publishing rather than an
unpinned global `npm install -g npm@latest`.

Co-authored-by: v0agent <[email protected]>
OIDC trusted publishing requires npm >= 11.5.1. Install npm 11 globally in
the release job before publishing.

Co-authored-by: v0agent <[email protected]>
@huozhi
huozhi force-pushed the oidc-trusted-publishing branch from d871658 to db1231d Compare June 21, 2026 10:38
@vercel vercel deleted a comment from vercel Bot Jun 21, 2026
@huozhi
huozhi merged commit 11bbc8f into main Jun 22, 2026
6 checks passed
@huozhi
huozhi deleted the oidc-trusted-publishing branch June 22, 2026 14:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants