ci: switch npm publishing to trusted publishing (OIDC) + manual backfill#233
Conversation
The npm-publish job silently skipped every release since 0.4.x because NPM_TOKEN was never configured — the guard made the job green while @gitlawb/gl sat at 0.3.7 on the registry. Replace token auth entirely: - npm Trusted Publishing: the job's GitHub OIDC identity (id-token: write) is exchanged with the registry; no long-lived secret to configure, leak, or rotate. Provenance is attested automatically. All five @Gitlawb packages exist on the registry now, so OIDC no longer has the first-publish bootstrap problem that forced token auth in #127. - Fail loud: the secret guard is gone. If a package's trusted publisher isn't configured on npmjs.com, the publish errors visibly instead of green-skipping. - setup-node 24 + npm >=11.5.1 (OIDC exchange support; older npm falls back to absent token auth with a confusing error). - workflow_dispatch backfill: publish an already-cut GitHub release (e.g. v0.6.0) to npm by tag — binaries come from the existing release assets, so only the npm-publish job runs.
|
Important Review skippedNo new commits to review since the last review. ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughThe release workflow now supports manual npm backfills from existing release tags, skips release-please during dispatches, and publishes packages using npm trusted publishing with GitHub OIDC provenance. ChangesNPM publishing workflow
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant GitHubActions
participant ReleasePlease
participant GitTag
participant NpmRegistry
GitHubActions->>ReleasePlease: Read release tag for normal publishing
GitHubActions->>GitHubActions: Select and validate resolved tag
GitHubActions->>GitTag: Checkout release tag and stage binaries
GitHubActions->>NpmRegistry: Publish packages with OIDC provenance
NpmRegistry-->>GitHubActions: Return publish result
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
.github/workflows/release.yml (2)
268-276: 🔒 Security & Privacy | 🔵 Trivial | ⚡ Quick winConsider guarding the dispatch branch by repository, like
release-pleasedoes.
release-pleaserestricts execution togithub.repository == 'Gitlawb/node', but the second branch of thisif(github.event_name == 'workflow_dispatch' && inputs.npm_backfill_tag != '') has no such check. On a fork, a manually triggeredworkflow_dispatchwith a tag set would still satisfy this condition and attempt to rungh release download/npm publishusing the fork's ownGITHUB_TOKEN/OIDC identity. The actualnpm publishwould likely fail registry-side (trusted publisher is bound to this repo+workflow), but the job would still spend fork secrets/CI time and produce a confusing failure instead of a clean skip.Proposed fix
if: >- ${{ !cancelled() && ( (needs.release-please.outputs.release_created == 'true' && needs.release-binaries.result == 'success') || - (github.event_name == 'workflow_dispatch' && inputs.npm_backfill_tag != '') + (github.repository == 'Gitlawb/node' && github.event_name == 'workflow_dispatch' && inputs.npm_backfill_tag != '') ) }}🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In @.github/workflows/release.yml around lines 268 - 276, Update the workflow job condition so the manual npm backfill branch also requires github.repository == 'Gitlawb/node', matching the existing release-please branch. Preserve the current release-created and successful-binaries condition while preventing workflow_dispatch runs with npm_backfill_tag from executing on forks.
299-310: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueNode/npm bootstrap matches trusted-publishing requirements; zizmor hint is a benign false positive here.
npm trusted publishing requires npm CLI ≥11.5.1 (and Node ≥22.14.0); Node 24 +
npm@^11.5.1satisfies both.actions/setup-node@v5.0.0does supportnode-version: "24". The zizmoradhoc-packageswarning on line 309 is a generic heuristic for any package install outside a lockfile — here it's bootstrapping the CLI tool itself (not an app dependency), so it's a reasonable false positive; if you want to silence it, exact-pinning (npm@11.5.1) instead of the caret range would be marginally more reproducible, though the caret already enforces the OIDC-capable floor.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In @.github/workflows/release.yml around lines 299 - 310, Update the npm bootstrap command in “Ensure npm supports trusted publishing” to install the exact version 11.5.1 instead of using the caret range, preserving the existing verification and Node 24 setup.Source: Linters/SAST tools
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.github/workflows/release.yml:
- Around line 7-16: Update the release-please job-level if condition to require
github.event_name != 'workflow_dispatch' in addition to the existing repository
check. This must skip release-please during manual npm backfill runs while
preserving its behavior for other workflow events.
---
Nitpick comments:
In @.github/workflows/release.yml:
- Around line 268-276: Update the workflow job condition so the manual npm
backfill branch also requires github.repository == 'Gitlawb/node', matching the
existing release-please branch. Preserve the current release-created and
successful-binaries condition while preventing workflow_dispatch runs with
npm_backfill_tag from executing on forks.
- Around line 299-310: Update the npm bootstrap command in “Ensure npm supports
trusted publishing” to install the exact version 11.5.1 instead of using the
caret range, preserving the existing verification and Node 24 setup.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: b0951583-4e59-46ad-a86b-70b5e3592f2a
📒 Files selected for processing (1)
.github/workflows/release.yml
A backfill run must be a narrow npm-only operation. Without an event guard, workflow_dispatch also ran release-please with contents+PR write permissions and could create or advance a release PR as a side effect. npm-publish is unaffected: its !cancelled() condition tolerates the skipped need, and all other jobs already gate on release_created.
|
@coderabbitai please review again approve if its all good! |
|
✅ Action performedReview finished.
|
|
@coderabbitai please check again theres a latest commit make sure we are good |
|
✅ Action performedReview finished.
|
The npm-publish job silently skipped every release since 0.4.x because NPM_TOKEN was never configured — the guard made the job green while @gitlawb/gl sat at 0.3.7 on the registry. Replace token auth entirely:
Summary by CodeRabbit
New Features
Bug Fixes