Skip to content

Commit a1fa56d

Browse files
Paul Mulliganclaude
andcommitted
ci: publish to npm via trusted publishing (OIDC)
Switch the manual npm publish workflow from a long-lived NPM_TOKEN secret to npm Trusted Publishing: - Remove NODE_AUTH_TOKEN from the publish step so npm authenticates via the GitHub Actions OIDC token (id-token: write is already granted) against the trusted publisher configured on each package at npmjs.com. - Upgrade the runner's npm to latest before publishing; Trusted Publishing needs npm >= 11.5.1 and Node 20 ships npm 10.x. - Update the header comment to document the new auth model. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent ee94763 commit a1fa56d

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

.github/workflows/publish-npm.yml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@ name: Publish to npm
88
# current version already exists, so re-running release-please is a no-op), and
99
# - recovering from a failed release publish without waiting for the next release.
1010
#
11-
# Requires the NPM_TOKEN secret to be an npm token that can publish the package
12-
# (and create it on first publish) and bypasses 2FA — a granular token with
13-
# "All packages" + read/write, or an account-scoped token. Publishes with
14-
# provenance (needs id-token).
11+
# Auth uses npm Trusted Publishing (OIDC) — there is no NPM_TOKEN secret. A
12+
# trusted publisher matching this repo + workflow filename must be configured
13+
# on each package at npmjs.com. Requires id-token: write and npm >= 11.5.1, so
14+
# we upgrade the runner's bundled npm before publishing. Provenance is
15+
# generated automatically.
1516
on:
1617
workflow_dispatch:
1718
inputs:
@@ -56,13 +57,15 @@ jobs:
5657
cache: pnpm
5758
cache-dependency-path: ${{ inputs.package }}/pnpm-lock.yaml
5859

60+
# Trusted Publishing (OIDC) needs npm >= 11.5.1; Node 20 ships npm 10.x.
61+
- name: Upgrade npm for trusted publishing
62+
run: npm install -g npm@latest
63+
5964
- name: Install
6065
run: pnpm install --frozen-lockfile
6166

6267
- name: Build
6368
run: pnpm build
6469

6570
- name: Publish
66-
env:
67-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
6871
run: npm publish --provenance --access public --tag "${{ inputs.dist-tag }}"

0 commit comments

Comments
 (0)