Migrate to npm Trusted Publisher with pinned npm version#8
Conversation
Co-authored-by: jimaek <1834071+jimaek@users.noreply.github.com>
WalkthroughThe changes modify the NPM package publishing pipeline by transitioning the authentication mechanism and adding provenance support. The workflow now grants specific permissions including id-token write access, upgrades the Node action to v4 with an explicit registry URL configuration, and removes the NPM token environment variable. The publish script removes the npm config authentication step and adds the 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 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 |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In @.github/workflows/publish_npm.yml:
- Around line 23-26: The workflow uses actions/setup-node@v4 with node-version:
'18' but relies on npm's --provenance flag which requires npm >= 9.5.0; either
pin npm to a known compatible version (e.g., run npm install -g npm@10 after
setup-node) or remove the --provenance option from the npm publish step. Locate
the publish step that invokes npm publish --provenance and update it to first
install a pinned npm (or change the publish command to omit --provenance) so the
workflow behavior is deterministic.
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: '18' | ||
| registry-url: 'https://registry.npmjs.org' |
There was a problem hiding this comment.
🧩 Analysis chain
🌐 Web query:
npm publish --provenance minimum version requirement
💡 Result:
npm publish --provenance requires npm CLI v9.5.0 or later (older npm versions don’t support npm provenance). [1]
If you’re using Trusted Publishing (OIDC) instead of tokens, that feature requires npm CLI v11.5.1+, and provenance attestations are generated automatically (so you typically don’t need --provenance). [2]
🌐 Web query:
GitHub Actions ubuntu-latest Node 18 default npm version
💡 Result:
Web search failed: Server error: no LLM provider could handle the message
🌐 Web query:
Node.js 18 default npm version bundled
💡 Result:
It depends on the exact Node.js 18.x.y release (the bundled npm version changes across minors/patches):
- Node.js 18.20.8 bundles npm 10.8.2. [1]
- The initial Node.js 18.0.0 release bundled npm 8.6.0. [2]
- Example mid-line: Node.js 18.18.0 bundled npm 9.8.1. [3]
To confirm what you have installed locally: node -p "process.versions.npm".
🌐 Web query:
GitHub Actions ubuntu-latest runner Node 18 npm version
💡 Result:
Web search failed: Server error: no LLM provider could handle the message
🌐 Web query:
actions/setup-node v4 node-version 18 resolves which version
💡 Result:
actions/setup-node@v4 treats node-version: 18 as a SemVer range meaning “latest available 18.x.y that satisfies 18” (not a fixed patch release). It will:
- Prefer a matching Node 18 already in the runner tool cache (SemVer match), and use the best match it finds.
- If not found, download a Node 18 build (preferably from
actions/node-versions, otherwise from the official Node.js distributions).
So the exact18.x.yyou get can vary over time and by runner image contents unless you pin it. [1]
To know what you actually got in a run, add:
- run: node -vIf you need a deterministic version, set an explicit patch (e.g. 18.20.5) instead of 18. [1][2]
Sources: [1] (setup-node README / v4 docs), [2] (GitHub Actions “Building and testing Node.js” examples using 18.x with `setup-node@v4).
🌐 Web query:
GitHub Actions ubuntu-latest Node.js 18 latest version 2026
💡 Result:
runs-on: ubuntu-latest(GitHub Actions) in 2026: it maps to Ubuntu 24.04 (the migration to make 24.04 theubuntu-latestdefault completed by Jan 17, 2025). [1]- “Node.js 18 latest version” (as of 2026): Node.js 18 is end-of-life, so the last (and thus “latest”) 18.x release remains v18.20.8 (2025-03-27). [2]
- If you use
actions/setup-nodewithnode-version: 18, it will resolve a matching 18.x version (from cache / node-versions, otherwise Node.js dist). [3]
Sources: [1] GitHub actions/runner-images announcement on ubuntu-latest → 24.04 rollout, [2] official Node.js v18.20.8 release post, [3] actions/setup-node documentation.
Consider adding an explicit npm version or removing the --provenance flag if not required.
The npm --provenance feature requires npm v9.5.0+, and while recent Node 18 releases (18.18.0+) bundle compatible npm versions, using actions/setup-node@v4 with node-version: '18' does not guarantee a specific npm version—it resolves to the best available match in the runner's cache, which can vary. If your publish workflow relies on npm publish --provenance, either explicitly pin npm (e.g., npm install -g npm@10) or clarify whether provenance attestation is actually needed (GitHub's Trusted Publishing / OIDC may handle this automatically without the flag).
🤖 Prompt for AI Agents
In @.github/workflows/publish_npm.yml around lines 23 - 26, The workflow uses
actions/setup-node@v4 with node-version: '18' but relies on npm's --provenance
flag which requires npm >= 9.5.0; either pin npm to a known compatible version
(e.g., run npm install -g npm@10 after setup-node) or remove the --provenance
option from the npm publish step. Locate the publish step that invokes npm
publish --provenance and update it to first install a pinned npm (or change the
publish command to omit --provenance) so the workflow behavior is deterministic.
Co-authored-by: jimaek <1834071+jimaek@users.noreply.github.com>
…rminism Co-authored-by: jimaek <1834071+jimaek@users.noreply.github.com>
Replaces token-based npm authentication with OIDC Trusted Publisher. Pins npm to
~10.9.0to ensure--provenanceflag compatibility (requires npm >= 9.5.0).Changes
Workflow (
.github/workflows/publish_npm.yml):id-token: write,contents: read)registry-urlinactions/setup-node@v4npm install -g npm@~10.9.0NPM_TOKENsecretPublish script (
.bin/publish_npm):--provenanceflag tonpm publishnpm Version Strategy
Using
~10.9.0(tilde range):--provenancesupport across all runsAuthentication Flow
The npm registry has been pre-configured to trust this repository and workflow file for publishing.
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
https://api.github.com/repos/actions/setup-node/contents/action.yml/usr/bin/curl curl -s REDACTED(http block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.