ci: publish to NPM through trusted publishing - #399
Merged
Conversation
The release job had no NPM credentials at all since NPM_TOKEN was dropped in 3690bd1, so `changeset publish` failed with ENEEDAUTH for every package once the devEngines blocker was out of the way. The changesets action logged it plainly: "No NPM_TOKEN or OIDC available - assuming npm is already authenticated". Grant the job an OIDC token so the action takes its trusted publishing path instead, which needs no long-lived token. Declaring permissions narrows them from the permissive default, so the contents and pull-requests scopes the action already used are spelled out as well. Requires a trusted publisher configured on npmjs.com for each published package, pointing at this repository and this workflow file. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01P2UZcjV4P98WFjzfRfLQvx
kraenhansen
force-pushed
the
claude/react-native-node-api-ci-0uc7tc
branch
from
August 11, 2026 08:53
ba12b89 to
ddd895f
Compare
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 #396. That PR got
changeset publishpast npm'sdevEnginescheck, and the next Release run then failed one step later, on authentication:The step had no npm credentials of any kind —
NPM_TOKENwas dropped in 3690bd1 ("Update release to use themainenvironment") and nothing has been published since 2026-01-05. The action says so itself, before running the publish script:changesets/action@v1.9.0picks one of three paths: write an.npmrcfromNPM_TOKEN, use trusted publishing whenACTIONS_ID_TOKEN_REQUEST_TOKENandACTIONS_ID_TOKEN_REQUEST_URLare present, or assume npm is already logged in. It took the third, because the job had no OIDC token — the run'sGITHUB_TOKEN Permissionsgroup lists Actions, Attestations, Contents, PullRequests and friends as write, but no id-token.The change
Grant the job an OIDC token so the action takes its trusted publishing path. No long-lived token to store or rotate, and npm generates provenance for the published packages as a side effect.
The one subtlety: this job currently runs on the permissive default token, and declaring
permissions:at all narrows it to exactly what is listed. So the two scopes the action was already relying on are spelled out alongside the new one:contents: write— version commits, git tags and GitHub releasespull-requests: write— the "Version Packages" PRid-token: write— npm trusted publishingNeeds npm-side configuration before this works
On npmjs.com, each published package needs a trusted publisher pointing at this repository and this workflow — I can't do this part, and the publish will keep failing with
ENEEDAUTHuntil it's in place:callstackincubator/react-native-node-apirelease.ymlmainto match the job'senvironment: main— if it's set to anything else the exchange is rejectedThe 7 publishable packages:
react-native-node-api,cmake-rn,cmake-file-api,ferric-cli,gyp-to-cmake,weak-node-api,@react-native-node-api/cli-utils. Only four are behind right now, but the other three will need it for their next release.Notes
npm publish. Worth knowing for later: pnpm#11513 reports OIDC publishing regressing in pnpm 11, so bumping the pinned pnpm major deserves a check against this workflow.npm_config_forcefrom ci: unblock changesets publish from npm's devEngines check #396 stays for now — it is still needed for thenpm infocalls thatchangeset publishmakes. Upgrade to Changesets v3 and changesets/action v2 #397 tracks removing it along with the Changesets v3 upgrade.Generated by Claude Code