Repository navigation
fix(ci): stop the publish job presenting a placeholder credential - #19
Merged
Merged
Conversation
setup-node writes `_authToken=${NODE_AUTH_TOKEN}` into the job's .npmrc when
given a registry-url, and exports a placeholder value when nothing supplies one.
npm presented that placeholder and failed with ENEEDAUTH instead of falling back
to the OIDC exchange trusted publishing relies on, which is how the v1.0.0
publish failed.
Bind NODE_AUTH_TOKEN to the same secret the action's token input uses: a real
token authenticates as before, and no token resolves empty, which is the
condition under which npm reaches for OIDC.
4 tasks done
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.
What and why
The v1.0.0 publish failed with
ENEEDAUTHwhile the job environment showed:That value is not set anywhere in this repository.
actions/setup-nodewrites_authToken=${NODE_AUTH_TOKEN}into the job's.npmrcwheneverregistry-urlis given, and exports that placeholder when nothing supplies a value. npm
therefore believed it held a credential, presented the placeholder, and failed —
rather than falling back to the OIDC exchange that trusted publishing depends
on.
The runner was not the constraint: Node 24.20.0 and npm 11.19.0, both past the
npm 11.5.1 / Node 22.14.0 trusted publishing requires.
Binding
NODE_AUTH_TOKENto the same secret the action'stokeninput alreadyuses covers both states: a real token authenticates as it does for the other
packages here, and no token resolves empty, which is the condition under which
npm attempts OIDC.
This does not by itself make the first publish work. A trusted publisher is
configured per package and cannot be configured for a name that does not exist,
and staged publishing is explicit that "the package already exists on the npm
registry — you cannot stage a brand-new package". The first publish needs a
token; this change is what makes every publish after it able to go tokenless.
Closes #18
Verification
How this was verified
actionlintpasses on the edited workflow. The diagnosis comes from the failedrun's own logs: the placeholder in the step environment,
ENEEDAUTHfrom npm,and the runner's npm version read from the setup step rather than assumed. The
tokenless path can only be confirmed once a trusted publisher exists, which
requires the package to be published first.