Publish npm via OIDC trusted publishing - #189
Merged
Merged
Conversation
The npm preview publish was failing with a 404 on the PUT request:
npm error 404 Not Found - PUT https://registry.npmjs.org/@crestapps%2fai-chat-ui
For scoped packages npm masks 401/403 as 404, so this was an auth failure:
the NPM_TOKEN secret was expired/revoked (the package publishes fine and was
last published 2.0.0-preview.175 on Sep 11). Rather than rotate another
expiring token, switch to npm OIDC trusted publishing.
Merge publish_npm_preview.yml and publish_npm_release.yml into a single
publish_npm.yml, since npm allows only one trusted publisher per package.
The one workflow handles manual/scheduled preview publishes (preview dist-tag)
and tag-triggered releases (latest dist-tag). Add id-token: write, upgrade the
runner npm to >= 11.5.1 (Node 20 ships npm 10.x), and drop NODE_AUTH_TOKEN.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This was referenced Sep 14, 2026
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.
Problem
The npm preview publish workflow was failing:
The build and packaging succeed — this is the upload being rejected. For scoped packages npm deliberately returns 404 on
PUTwhen the request isn't authorized (it masks 401/403 to avoid leaking existence). The package exists and published fine through2.0.0-preview.175on 2026-09-11; the two failing runs on 2026-09-14 were manualworkflow_dispatchruns — the first time auth was exercised since. In short: theNPM_TOKENsecret expired/was revoked.Fix
Rather than rotate another expiring token, switch to npm OIDC trusted publishing (short-lived per-run token, scoped to this repo + workflow, nothing to leak or expire).
Because npm allows only one trusted publisher per package, the two publish workflows are merged into a single
publish_npm.yml:workflow_dispatchpreviewschedule(daily)previewpushtagv*.*.*latestChanges:
id-token: writepermission for OIDC.npm install -g npm@latest; Node 20 ships npm 10.x, which predates trusted publishing).NODE_AUTH_TOKEN/NPM_TOKENentirely.publish_npm_preview.ymlandpublish_npm_release.yml.publish_npm.yml, and tag/release runs are excluded from that check by thebranch=mainfilter.Required manual setup (done on npmjs.com)
Trusted publisher configured on
@crestapps/ai-chat-ui: GitHub Actions provider, orgCrestApps, repoCrestApps.Core, workflow filenamepublish_npm.yml, no environment, "Allow npm publish" enabled (required for unattended publishing).Verification
OIDC can only be validated from
main. After merge, triggerpublish_npm.ymlviaworkflow_dispatchto confirm the first token-free publish succeeds. The now-unusedNPM_TOKENrepo secret can then be deleted.🤖 Generated with Claude Code