fix(ci): harden npm trusted publishing (OIDC) in release workflows#130
Merged
Conversation
Both release-please.yml and publish-npm.yml could run `npm publish` under Node's bundled npm (10.x), which predates OIDC trusted publishing and fails with ENEEDAUTH, and they inherited a deprecated `always-auth` key from the .npmrc that actions/setup-node generates (npm >= 11 warns "Unknown user config always-auth"). - Replace `npm install -g npm@latest` with a pinned `npm install -g npm@^11`, then assert npm >= 11.5.1 and prepend the freshly installed npm's global bin dir to PATH so the publish steps cannot silently fall back to bundled npm. - Add a "Sanitize npm config for OIDC" step that strips `always-auth` and the placeholder `_authToken` from setup-node's generated .npmrc, keeping the `registry=` line that OIDC needs. - Document that each package's npm trusted publisher is bound to the repo and the exact workflow filename, so renaming these files breaks publishing until the trusted-publisher config is updated to match. Stays tokenless: no NPM_TOKEN secret is introduced. Job permissions (id-token: write, plus contents: write for release-please) are unchanged. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
GitHub is force-migrating Node 20 actions to Node 24. Bump to the latest majors that run on Node 24: - actions/checkout v4 -> v7 - actions/setup-node v4 -> v6 - pnpm/action-setup v4 -> v6 - googleapis/release-please-action v4 -> v5 Verified against our usage: release-please-action v5's only breaking change is the Node 24 runtime (outputs and config/manifest interface unchanged); setup-node v6 honours our explicit `cache: pnpm` and no longer writes the deprecated always-auth key at the source; pnpm/action-setup v6 still accepts `version: 9`; checkout v7's fork-PR restriction does not apply to our push-triggered runs. Kept separate from the OIDC hardening commit so it can be reverted on its own if any action's new major changes behavior. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Hardens npm Trusted Publishing (OIDC) in both release workflows so automated and manual publishes reliably authenticate tokenlessly. Fixes the manual workflow's
ENEEDAUTHand the automated workflow'snpm warn Unknown user config "always-auth".Changes
Commit 1 —
fix(ci): OIDC hardening (release-please.yml+publish-npm.yml)npm install -g npm@latestwith a pinnednpm install -g npm@^11, then assert npm ≥ 11.5.1 (sort -Vguard) and prepend the freshly-installed npm's global bin toPATHvia$GITHUB_PATH, so the publish steps cannot silently fall back to Node's bundled npm 10.x. The job now fails loudly instead of publishing under an OIDC-incapable npm.always-authkey and the placeholder_authTokenfrom the.npmrcthatactions/setup-nodegenerates ($NPM_CONFIG_USERCONFIG), keeping theregistry=line OIDC needs.NPM_TOKEN. Permissions unchanged (id-token: write; pluscontents: writefor release-please).Commit 2 —
ci(deps): action bumps to Node 24 majors (separate, revertible)actions/checkoutv4→v7,actions/setup-nodev4→v6,pnpm/action-setupv4→v6,googleapis/release-please-actionv4→v5.Why this fixes the failures
npm publishruns under ≥ 11.5.1.actions/setup-node@v4writesalways-auth=falseinto its generated.npmrc; npm ≥ 11 rejects it as unknown config. The sanitize step removes it (and the placeholder token);setup-node@v6also stops writing it at the source.Test plan
js-yaml).@v4action refs remain; bumped versions confirmed.release-please.ymlon merge tomain) authenticates via OIDC with noalways-authwarning; manualpublish-npm.ymldispatch (after temporarily repointing the package's trusted publisher topublish-npm.yml) publishes withoutENEEDAUTH.Notes
.npmrcexists anywhere in the repo (root,widget/,create-claudius/,worker/,docs/) — thealways-authwarning came solely from setup-node's runtime-generated file, which the sanitize step cleans in-job.🤖 Generated with Claude Code