ci: strip forced placeholder token so npm publish uses OIDC - #7
Merged
Conversation
The setup-node .npmrc sets always-auth=true with a placeholder _authToken, which forced npm to publish with the fake token (E404) instead of doing the OIDC exchange. Overwrite that .npmrc with only the registry line so npm has no token and authenticates via OIDC trusted publishing. Also log npm --version.
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.
Third follow-up. The run log revealed the real blocker: setup-node's
.npmrc($NPM_CONFIG_USERCONFIG) setsalways-auth=truealongside a placeholder_authToken(NODE_AUTH_TOKEN: XXXXX-...). That forces npm to authenticate with the fake token on every request →E404, never reaching the OIDC exchange.Fix: before publishing, overwrite that
.npmrcwith onlyregistry=https://registry.npmjs.org/. With no token present, npm (≥ 11.5.1) authenticates via the OIDC id-token exchange (trusted publishing). Addednpm --versionto confirm the version.If this still 404s, the remaining suspect is the Trusted Publisher config on npm (repo/workflow-filename mismatch) — but this removes the last token-shadowing issue on our side.