fix(ci): add environment: npm to wasm publish for Trusted Publishing#2239
Conversation
The npm Trusted Publisher config has Environment name set to 'npm', which means the OIDC token must include an 'environment' claim. GitHub only emits that claim when the job runs in a deployment environment. The publish job didn't declare one, so npm rejected the publish (seen as ENEEDAUTH after #2235 / 404 before it). Add environment: npm to the build-and-publish job. The 'npm' environment must exist under repo Settings -> Environments — that's where you can also gate releases with required reviewers / branch restrictions. Also restore registry-url on setup-node. Removing it in #2235 was the wrong direction: the official npm Trusted Publishers docs keep it set, and the actual blocker was the missing environment claim, not the auto-written .npmrc.
|
Caution Review failedPull request was closed or merged during review No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughThe workflow configures npm Trusted Publisher authentication by adding an Changesnpm Trusted Publisher Configuration
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
The wasm publish job is still failing — most recently with
ENEEDAUTH(https://github.com/Canner/WrenAI/actions/runs/25354035171/job/74339499436). The npm CLI never went through the OIDC handshake.The npm Trusted Publisher config for
@wrenai/wren-core-wasmhas Environment name:npmset. With that field set, npm requires the OIDC token to carry anenvironment: npmclaim. GitHub only adds that claim when the job runs inside a deployment environment, and our publish job didn't declare one — so npm rejected the publish. (Before #2235 the symptom was a 404; after, it'sENEEDAUTH. Both are downstream symptoms of the same missing claim.)Fix
environment: npmto thebuild-and-publishjob.registry-url: https://registry.npmjs.orgonsetup-node. Removing it in fix(ci): drop registry-url from setup-node so wasm publish uses OIDC #2235 was the wrong direction — the npm Trusted Publishers docs explicitly set it, and the real blocker wasn't the auto-written.npmrcbut the missing environment claim.Required repo setup
Before merging, create a GitHub Actions environment named
npm:(That's the same name configured on npm's side.) Optional but recommended: protect it with required reviewers and a branch restriction so only
main(or release branches) can publish.If the environment doesn't exist when the workflow runs, the job will fail with a clear "environment not found" error.
Test plan
npmenvironment in repo settings.component=wren-core-wasmand confirmnpm publishsucceeds via OIDC.🤖 Generated with Claude Code
Summary by CodeRabbit