ci(release): don't let the credential pre-flight break tokenless publishing - #4
Merged
Merged
Conversation
…ishing The `npm credentials are valid` step added in #3 runs `npm whoami` before publishing, to turn npm's misleading 404-on-PUT into a plain statement that the token is dead. That is right for the token path and wrong for the one this repository should be moving to. Under trusted publishing there is no long-lived credential at all: the npm CLI exchanges the Actions OIDC token for a short-lived one during publish, and attests provenance without being asked. `npm whoami` has nothing to answer with and exits non-zero — so a repository configured exactly as npm recommends would fail this gate and never reach the publish it was ready to do. The check would have become a new cause of the red pipeline it was written to explain. It now returns early when NPM_TOKEN is unset, and only enforces `whoami` when a token is actually present. Diagnostic on the path that has a credential to diagnose; silent on the path that does not. This is not hypothetical maintenance. npm restricted 2FA-bypass granular access tokens on 2026-07-31: creating a package and setting its access now require an interactive 2FA challenge, and `npm publish --access public` against a name that has never been published does both. Direct publish is withdrawn from these tokens entirely in January 2027. The failure message now points at configuring a trusted publisher rather than at minting another token that will stop working. https://github.blog/changelog/2026-07-31-restricting-npm-bypass-2fa-granular-access-tokens/ Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HDC1iraSA12i16CWbHtAMm
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.
Follow-up to #3, found while trying to actually publish
webmobai-mcp@1.4.1.The bug
#3 added an
npm whoamipre-flight so that a dead token reports itself as adead token instead of as npm's misleading
404 Not Found - PUT. That iscorrect when a token exists. It is wrong when one does not.
Under trusted publishing there is no long-lived credential: the npm CLI
exchanges the Actions OIDC token for a short-lived one at publish time and
attests provenance automatically.
npm whoamihas nothing to answer with andexits non-zero — so a repository configured exactly the way npm recommends
would fail the gate and never reach a publish it was ready to perform. The
step written to explain a red pipeline would have become a fresh cause of one.
The gate now returns early when
NPM_TOKENis unset and enforceswhoamionlywhen a token is present.
Why this is urgent rather than tidy
npm restricted 2FA-bypass granular access tokens on 2026-07-31.
Creating a package and changing its access now require an interactive 2FA
challenge — and
npm publish --access publicagainst a name that has neverbeen published does both.
This is confirmed, not inferred. Publishing 1.4.1 with a valid
Publishtokenfor this account:
npm whoamiwith that same token returnscelikgo, andnpm profile getalso 403s. The credential authenticates and is refused for writes. Direct
publish is withdrawn from these tokens entirely in January 2027.
So the failure message no longer advises minting another token. It points at
configuring a trusted publisher and deleting the secret.
Consequence for the first publish
Trusted publishing is configured per-package in npmjs.com package settings,
which requires the package to exist.
webmobai-mcphas never been published,so v1.4.1's first publish has to happen interactively with a 2FA challenge;
trusted publishing can take over from the next release.
The
Is this version already on the registry?gate from #3 makes that sequencework without any special-casing: once 1.4.1 exists, the tag's publish job
detects it, skips the publish, and
verify-npmstill proves both documentedinstall paths from a clean runner.
Verification
Both branches of the gate exercised directly, plus YAML and
bash -noverevery
run:block in the file.