-
Notifications
You must be signed in to change notification settings - Fork 0
ci: switch npm publish to OIDC trusted publishing (removes NPM_TOKEN) #50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -79,13 +79,11 @@ jobs: | |||||||||||||||||
| - name: Test | ||||||||||||||||||
| run: pnpm test | ||||||||||||||||||
|
|
||||||||||||||||||
| - name: Configure npm auth | ||||||||||||||||||
| run: echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc | ||||||||||||||||||
| env: | ||||||||||||||||||
| NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | ||||||||||||||||||
| # npm Trusted Publishing (OIDC) requires npm >= 11.5.1. | ||||||||||||||||||
| # Node 22 ships an older npm; upgrade in-place for the publish step. | ||||||||||||||||||
| - name: Upgrade npm for OIDC | ||||||||||||||||||
| run: npm install -g npm@latest | ||||||||||||||||||
|
Comment on lines
+82
to
+85
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: # First, let's examine the release-please.yml file around the mentioned lines
cat -n .github/workflows/release-please.yml | sed -n '70,95p'Repository: cachekit-io/cachekit-ts Length of output: 828 🏁 Script executed: # Also check if there are other workflow files with npm upgrade steps
fd '.yml$|.yaml$' .github/workflows/ --exec grep -l "npm install -g npm" {} \;Repository: cachekit-io/cachekit-ts Length of output: 139 🏁 Script executed: # Let's check the complete context of the release-please.yml file to understand the structure
wc -l .github/workflows/release-please.ymlRepository: cachekit-io/cachekit-ts Length of output: 107 🏁 Script executed: # Check build-native.yml for npm upgrade context
grep -n -B5 -A5 "npm install -g npm" .github/workflows/build-native.ymlRepository: cachekit-io/cachekit-ts Length of output: 589 🏁 Script executed: # Let's verify the npm version requirements by checking if there's any documentation or package metadata
# Search for any references to npm versions in the repo
rg "11\.5\.1|npm.*version|trusted.*publish" -i --type yamlRepository: cachekit-io/cachekit-ts Length of output: 49 🏁 Script executed: # Check what version of npm is bundled with Node 22
# First, let's see if there's any documentation in the repo about npm/node versions
fd -e md -e txt | xargs rg "npm|node" -i | head -20Repository: cachekit-io/cachekit-ts Length of output: 597 🏁 Script executed: # Search for any existing npm version pins in the codebase
rg "npm@[0-9]" --type yamlRepository: cachekit-io/cachekit-ts Length of output: 49 🏁 Script executed: # Also check package.json files for engines specifications
fd package.json -x cat -n {} | grep -i "node\|npm"Repository: cachekit-io/cachekit-ts Length of output: 1341 🌐 Web query:
💡 Result: To use npm trusted publishing with OpenID Connect (OIDC), you must use npm CLI version 11.5.1 or later [1][2][3]. In addition to the CLI version requirement, official documentation specifies that Node.js version 22.14.0 or higher is required [1]. Trusted publishing allows you to publish packages directly from CI/CD environments (such as GitHub Actions or GitLab CI) without the need for long-lived npm access tokens [1][4]. To implement this, you must configure the trusted publisher settings on the npmjs.com package page and ensure your CI/CD workflow has the necessary permissions (e.g., Citations:
Pin the npm CLI version to the documented minimum for OIDC. Both ♻️ Proposed changesrelease-please.yml: - run: npm install -g npm@latest
+ run: npm install -g npm@11.5.1build-native.yml: - run: npm install -g npm@latest
+ run: npm install -g npm@11.5.1📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||
|
|
||||||||||||||||||
| - name: Publish to npm | ||||||||||||||||||
| - name: Publish to npm (OIDC trusted publisher) | ||||||||||||||||||
| working-directory: packages/cachekit | ||||||||||||||||||
| run: pnpm publish --access public --provenance --no-git-checks | ||||||||||||||||||
| env: | ||||||||||||||||||
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | ||||||||||||||||||
| run: npm publish --access public --provenance | ||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: cachekit-io/cachekit-ts
Length of output: 1346
🏁 Script executed:
Repository: cachekit-io/cachekit-ts
Length of output: 1226
🏁 Script executed:
Repository: cachekit-io/cachekit-ts
Length of output: 104
🏁 Script executed:
Repository: cachekit-io/cachekit-ts
Length of output: 1082
🏁 Script executed:
Repository: cachekit-io/cachekit-ts
Length of output: 217
🏁 Script executed:
Repository: cachekit-io/cachekit-ts
Length of output: 691
🌐 Web query:
npm trusted publishing OIDC version requirement Node 22💡 Result:
To use npm trusted publishing with OpenID Connect (OIDC), you must meet specific version requirements for both the npm CLI and Node.js. As of May 2026, official documentation requires npm CLI version 11.5.1 or later and Node.js version 22.14.0 or higher [1][2]. While some earlier versions of Node.js 22 may not include a compatible version of the npm CLI by default, you can satisfy the requirement by explicitly updating npm within your CI/CD workflow using the command npm install -g npm@latest [3][2]. If you are unable to update the npm CLI, you may encounter authentication errors, such as silent failures or 404 errors, because older versions of the npm client do not correctly handle the OIDC handshake [4]. In summary, ensure your environment uses: - npm CLI: 11.5.1 or later [1][3][2] - Node.js: 22.14.0 or later [1][2] Additionally, your CI/CD workflow must be configured with the necessary OIDC permissions (e.g., id-token: write for GitHub Actions) to generate the required tokens [1][5][6].
Citations:
Pin npm versions in both publish workflows instead of using
@latest.Lines 173-176 in
build-native.ymland lines 82-85 inrelease-please.ymlboth upgrade npm usingnpm install -g npm@latest. For OIDC trusted publishing on Node 22, npm 11.5.1+ is required. Using@latestmakes release workflows depend on future npm versions rather than a known-compatible baseline. Pin to a specific version (e.g.,npm@11.5.1) to ensure deterministic, reproducible releases and prevent unexpected breakage from major npm updates.♻️ Proposed changes
build-native.yml (lines 173-176):
release-please.yml (lines 82-85):
📝 Committable suggestion
🤖 Prompt for AI Agents