ci: publish through npm OIDC trusted publishing - #10
Merged
Merged
Conversation
npm rejected the 1.0.4 publish with 404 Not Found, npm's mask for an unauthorized publish - the NPM_TOKEN no longer authenticates. bun publish cannot perform the npm OIDC token exchange (oven-sh/bun#22423), so trusted publishing needs the publish command itself to be npm. changepacks selects that command from .changepacks/config.json, which overrides the bun.lock-derived default, matching how devup-ui publishes: bun packs the tarball so the packed manifest is unchanged, then npm publishes that tarball over OIDC. The workflow grants id-token: write, installs Node 24 with npm >= 11.5.1 (the trusted publishing floor), and drops NPM_CONFIG_TOKEN entirely - an empty token still counts as a value to npm and suppresses the OIDC exchange.
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
Run 34445643571 failed on publish:
The package does exist on npm (
latestis1.0.3), and the dry-run in the same job succeeded.404is npm's mask for an unauthorized publish — theNPM_TOKENno longer authenticates.Why the fix is not just
id-token: writebun publishcannot perform the npm OIDC token exchange (oven-sh/bun#22423, #15601); the implementation PR was closed unmerged. Bun's own release pipeline publishes its npm package withnpm publishfor this reason. Adding the permission alone would still fail, because changepacks resolves the publish command from the lockfile andbun.lockselectsbun publish.Changes
.changepacks/config.json— override thenodepublish command. This key takes precedence over lockfile detection, so changepacks stops callingbun publishwithout changing how the repo installs or builds. Same shape asdevup-ui: bun packs the tarball, so the packed manifest is byte-identical to what shipped before, then npm publishes that tarball over OIDC..github/workflows/publish.ymlid-token: write— lets npm exchange GitHub's short-lived OIDC token.actions/setup-node@v7(Node 24,registry-url) +npm install -g npm@latest— trusted publishing requires npm >= 11.5.1, above what the runner image ships.NPM_CONFIG_TOKENremoved. An empty token still counts as a value to npm and suppresses the OIDC exchange, so the variable has to be gone, not blank.actions/checkout@v4->@v7, clearing the Node 20 deprecation annotation on this run..changepacks/publish.tgzis already covered by the*.tgzentry in.gitignore.Required before merge
bun-test-env-dommust be registered as a Trusted Publisher at npmjs.com/package/bun-test-env-dom/access — without this the publish fails with the same 404.dev-five-gitbun-test-env-dompublish.yml(filename only, not a path)npm matches these exactly and case-sensitively; a mismatch surfaces as the same
404, which is indistinguishable from the current failure.Verification
Ran locally against this branch:
bun pm pack --quiet --filename .changepacks/publish.tgz-> 7106 bytes, matching the 7.11 kB bun packed in the failing run.npm publish .changepacks/publish.tgz --dry-run-> same 6 files, 7.1 kB packed / 18.6 kB unpacked as the previous bun output.bun test(28 pass, 100% coverage) andbun lintpass via the pre-commit hook.setup-nodeand the npm upgrade both precedechangepacks/action.The same pattern is already publishing in this org —
@changepacks/cli@0.3.6shipped through it, anddevup-uiandcsstype-extrause it.Release
1.0.4is still pending as a draft with its tag pushed, so merging this picks that release back up rather than needing a new version.