Skip to content

ci: switch to npm trusted publishing (OIDC)#36

Merged
MuncleUscles merged 3 commits intomainfrom
ci/trusted-publishing
Feb 10, 2026
Merged

ci: switch to npm trusted publishing (OIDC)#36
MuncleUscles merged 3 commits intomainfrom
ci/trusted-publishing

Conversation

@MuncleUscles
Copy link
Member

@MuncleUscles MuncleUscles commented Feb 10, 2026

Summary

  • Switch from NPM_AUTH_TOKEN to npm OIDC trusted publishing with provenance
  • Add id-token: write permission for OIDC token exchange
  • Use npm publish --provenance instead of yarn workspace ... npm publish
  • Bump checkout/setup-node actions to v4

Trusted publisher config needed on npmjs.com

Package: genlayer-wallet-plugin

  • Repository owner: genlayerlabs
  • Repository name: genlayer-wallet
  • Workflow: deploy-snap.yml (and deploy-snap-beta.yml)
  • Environment: (leave blank)

Test plan

  • Configure trusted publisher on npmjs.com for genlayer-wallet-plugin
  • Trigger Deploy Snap Production workflow manually
  • Verify package publishes with provenance badge on npmjs.com

Summary by CodeRabbit

  • Chores
    • Deployment workflow updated to support selectable release channels (production or beta) with conditional prerelease handling.
    • Separate beta-only workflow removed and consolidated into the primary deployment flow.
    • Workflow actions and platform integration updated for improved compatibility and reliable package publishing (including conditional beta tagging and provenance).

- Add id-token: write permission for OIDC
- Add registry-url to setup-node
- Switch from yarn npm publish to npm publish --provenance
- Remove NPM_AUTH_TOKEN dependency
- Bump actions/checkout and actions/setup-node to v4
@coderabbitai
Copy link

coderabbitai bot commented Feb 10, 2026

📝 Walkthrough

Walkthrough

Deleted the dedicated beta publish workflow and updated the main snap deployment workflow to accept a required release channel input (production|beta), upgrade action versions, configure the npm registry, and conditionally publish/releases with beta tagging and prerelease support.

Changes

Cohort / File(s) Summary
Removed Beta Workflow
/.github/workflows/deploy-snap-beta.yml
Deleted the standalone beta release workflow that performed checkout, Node setup, workspace install/build, version extraction/patching, commit, GitHub Release creation, and npm publish with a beta tag.
Consolidated Deploy Workflow
/.github/workflows/deploy-snap.yml
Added required channel input (production

Sequence Diagram(s)

sequenceDiagram
  participant Dev as Developer (push/PR)
  participant GH as GitHub Actions Workflow (deploy-snap.yml)
  participant Runner as Actions Runner
  participant Registry as npm Registry
  participant Release as GitHub Release (softprops/action-gh-release)

  Dev->>GH: push / workflow_dispatch (channel)
  GH->>Runner: start job (checkout, setup-node, install, build)
  Runner->>Release: create GitHub Release (prerelease? channel==beta)
  Runner->>Registry: publish package (--tag beta if channel==beta)
  Registry-->>Runner: publish result
  Release-->>GH: release created
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰
I hopped through workflows, tidy and spry,
Merged beta and main beneath one sky,
Tags and prerelease now twine and play,
One carrot for builds, one path for the way. 🥕

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'ci: switch to npm trusted publishing (OIDC)' directly and clearly describes the main change in the pull request: migrating from NPM_AUTH_TOKEN-based publishing to npm OIDC trusted publishing.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch ci/trusted-publishing

Tip

Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Combines deploy-snap.yml and deploy-snap-beta.yml into one workflow
with a "channel" dropdown (production/beta). Only one workflow filename
needed for npm trusted publishing config.
@MuncleUscles MuncleUscles merged commit f55bc2f into main Feb 10, 2026
8 of 9 checks passed
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
.github/workflows/deploy-snap.yml (1)

62-62: ⚠️ Potential issue | 🟡 Minor

Upgrade softprops/action-gh-release to v2 or later.

This action currently uses v1, which targets the deprecated Node.js 16 GitHub Actions runtime. v2 targets Node.js 20 and has been stable since March 2024 (latest: v2.5.0). GitHub deprecated the Node.js 16 runtime with a June 30, 2024 sunset date.

Suggested fix
-        uses: softprops/action-gh-release@v1
+        uses: softprops/action-gh-release@v2
🤖 Fix all issues with AI agents
In @.github/workflows/deploy-snap.yml:
- Around line 71-78: The "Publish to npm" workflow step uses Node 20 (npm
v10.8.2) which doesn't support OIDC trusted publishing; either set a
NODE_AUTH_TOKEN secret for traditional token-based auth or upgrade the
setup-node action to Node 24+ so npm v11.5.1+ can use OIDC. Fix by updating the
workflow's setup-node `node-version` to 24 (or later) so the `npm publish`
commands (the block using inputs.channel and npm publish --provenance ...) run
with an npm that supports OIDC, or keep Node 20 but add an env entry exporting
NODE_AUTH_TOKEN from a GitHub secret and ensure the publish step uses that token
for authentication.
🧹 Nitpick comments (1)
.github/workflows/deploy-snap.yml (1)

47-51: Beta channel publishes a regular patch version under the beta dist-tag.

The version patch step (Line 49) bumps to a standard semver (e.g., 1.0.1) regardless of channel. For beta releases, it's conventional to use a prerelease identifier (e.g., 1.0.1-beta.0) so that the version itself signals its pre-release nature. Currently, a user who pins a specific version won't know it was a beta.

This is how the deleted deploy-snap-beta.yml likely handled it too, so if this is intentional, feel free to disregard.

Suggested approach for beta prerelease versioning
      - name: Patch version
        run: |
-          yarn workspace genlayer-wallet-plugin version patch
+          if [ "${{ inputs.channel }}" = "beta" ]; then
+            yarn workspace genlayer-wallet-plugin version prerelease --preid beta
+          else
+            yarn workspace genlayer-wallet-plugin version patch
+          fi
          VERSION=$(jq -r ".version" "packages/snap/package.json")
          echo "VERSION=$VERSION" >> "$GITHUB_ENV"

Also applies to: 71-78

Comment on lines 71 to +78
- name: Publish to npm
env:
YARN_NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
run: yarn workspace genlayer-wallet-plugin npm publish --access public
working-directory: packages/snap
run: |
if [ "${{ inputs.channel }}" = "beta" ]; then
npm publish --provenance --tag beta --access public
else
npm publish --provenance --access public
fi
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🌐 Web query:

npm oidc trusted publishing GitHub Actions 2025

💡 Result:

npm OIDC “Trusted Publishing” for GitHub Actions (status + setup, as of 2025)

  • What it is: A way to publish to npm from GitHub Actions without storing long‑lived npm tokens, by exchanging a GitHub Actions OIDC ID token for a short‑lived npm publish token. It’s generally available as of July 31, 2025. [2]
  • Requirements / key behaviors:
    • Requires npm CLI v11.5.1+. [1], [2]
    • Your workflow/job must request an OIDC token via permissions: id-token: write (and typically contents: read). [1], [3]
    • Works on GitHub-hosted runners (self-hosted runner support noted as a future improvement). [1]
    • When using trusted publishing, npm CLI publishes provenance attestations by default (no need to pass --provenance). [2]

Setup (high level)

  1. On npmjs.com (per package): Add a Trusted Publisher → GitHub Actions, specifying owner/org, repo, workflow filename, and optionally an environment name. [2], [1]
  2. In GitHub Actions workflow: Ensure OIDC permissions are granted:
permissions:
  contents: read
  id-token: write

This id-token: write permission is required for GitHub to mint the OIDC JWT your job will use. [3], [1]

Sources: npm docs on trusted publishers [1], GitHub changelog announcement (GA, provenance defaults) [2], GitHub Actions OIDC permissions docs [3].


🌐 Web query:

setup-node registry-url oidc authentication

💡 Result:

To use OIDC authentication with actions/setup-node (i.e., publish to npm without NODE_AUTH_TOKEN), you need npm “Trusted Publishing” plus the GitHub OIDC token permission.

1) Configure npm “Trusted Publisher”

In npmjs.com → your package → Settings → Trusted Publisher → GitHub Actions, register:

  • owner/org, repo, and workflow filename (optionally an environment). (docs.npmjs.com)

2) GitHub Actions workflow (OIDC publish)

name: Publish

on:
  push:
    tags: ['v*']

permissions:
  contents: read
  id-token: write   # required for OIDC

jobs:
  publish:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - uses: actions/setup-node@v4
        with:
          node-version: '24'
          registry-url: 'https://registry.npmjs.org'

      - run: npm ci
      - run: npm publish --provenance

Key points:

  • permissions: id-token: write is the critical requirement for OIDC. (docs.npmjs.com)
  • setup-node’s registry-url configures the registry and expects auth via NODE_AUTH_TOKEN for classic token flows, but with Trusted Publishing, npm can authenticate the publish via OIDC (no secret needed). (github.com)

3) When you still need NODE_AUTH_TOKEN

If your workflow must install private npm dependencies, you still need a (read-only) token for npm ci; OIDC is “publish-only”. (docs.npmjs.com)

Note (semantic-release)

If you publish via semantic-release, their docs warn that setting registry-url in setup-node can conflict with semantic-release’s auth handling (they recommend omitting it). (semantic-release.gitbook.io)

Citations:


🌐 Web query:

npm cli oidc trusted publishing NODE_AUTH_TOKEN required

💡 Result:

With npm Trusted Publishing (OIDC), NODE_AUTH_TOKEN is not required for npm publish.

  • The npm CLI (npm ≥ 11.5.1) will detect an OIDC environment and use it for publish auth, falling back to traditional tokens only if OIDC isn’t available. So a token env var is only needed when you’re not actually publishing via OIDC. [1]
  • GitHub Actions requirement: your workflow must grant id-token: write so GitHub can mint the OIDC token. [1]
  • When NODE_AUTH_TOKEN is needed: if your workflow must install private npm dependencies (e.g., during npm ci), you still need traditional auth for install, and npm recommends a read-only token via NODE_AUTH_TOKEN for that step. [1]
  • Many token-based examples (and actions/setup-node) use NODE_AUTH_TOKEN because they’re writing an .npmrc that references it—this is the classic/granular token path, not OIDC. [2]

If you’re seeing an error like “NODE_AUTH_TOKEN required” during publish, the usual causes are: you’re not on npm ≥ 11.5.1, you haven’t configured the package’s Trusted Publisher on npm, or your CI isn’t providing OIDC (id-token: write). [1]

Sources: npm Trusted Publishing docs [1]; GitHub “Publishing Node.js packages” docs (token-based .npmrc/NODE_AUTH_TOKEN) [2].


🏁 Script executed:

cat -n .github/workflows/deploy-snap.yml | head -80

Repository: genlayerlabs/genlayer-wallet

Length of output: 2855


🏁 Script executed:

grep -A 10 "permissions:" .github/workflows/deploy-snap.yml

Repository: genlayerlabs/genlayer-wallet

Length of output: 290


🌐 Web query:

Node.js 20 npm version bundled included

💡 Result:

Node.js 20 bundles npm, but the exact npm version depends on the specific Node 20 release:

  • Node.js v20.0.0 shipped with npm v9.6.4. [3]
  • The latest Node.js 20 line (e.g., v20.20.0, updated Jan 12, 2026) bundles npm v10.8.2. [1][2]

To confirm on your machine: npm -v (or node -p "process.versions.npm").


🌐 Web query:

Node.js version npm 11.5.1 bundled which version

💡 Result:

npm 11.5.1 is bundled with Node.js v24.5.0. [1]

Sources: Node.js download archive for v24.5.0 (shows “npm version v11.5.1”). [1]

[1] (nodejs.org)

Citations:


Node 20's npm version (v10.8.2) does not support OIDC trusted publishing—either add NODE_AUTH_TOKEN or upgrade to Node 24+.

npm OIDC trusted publishing (now GA) requires npm v11.5.1+, which is only bundled with Node.js v24.5.0 and later. The workflow uses Node 20, which bundles npm v10.8.2 (below the required version). This will cause authentication to fail during npm publish.

To fix: either set NODE_AUTH_TOKEN (via a GitHub secret) for traditional token-based authentication, or upgrade node-version to 24 or later.

🤖 Prompt for AI Agents
In @.github/workflows/deploy-snap.yml around lines 71 - 78, The "Publish to npm"
workflow step uses Node 20 (npm v10.8.2) which doesn't support OIDC trusted
publishing; either set a NODE_AUTH_TOKEN secret for traditional token-based auth
or upgrade the setup-node action to Node 24+ so npm v11.5.1+ can use OIDC. Fix
by updating the workflow's setup-node `node-version` to 24 (or later) so the
`npm publish` commands (the block using inputs.channel and npm publish
--provenance ...) run with an npm that supports OIDC, or keep Node 20 but add an
env entry exporting NODE_AUTH_TOKEN from a GitHub secret and ensure the publish
step uses that token for authentication.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant