Skip to content

feat(ci): publish to npm via OIDC trusted publishing - #124

Merged
emmanuelnk merged 1 commit into
mainfrom
feat/npm-trusted-publishing
Aug 11, 2026
Merged

feat(ci): publish to npm via OIDC trusted publishing#124
emmanuelnk merged 1 commit into
mainfrom
feat/npm-trusted-publishing

Conversation

@emmanuelnk

Copy link
Copy Markdown
Owner

Problem

Publishing auths with a long-lived NPM_TOKEN secret that keeps expiring — the latest beta publish failed with npm E404 (PUT .../@github-actions-workflow-ts%2flib - Not found), which is how npm reports an invalid/expired token for scoped packages.

Solution

Switch to npm trusted publishing (OIDC): the publish job declares id-token: write and pnpm exchanges the runner's OIDC identity for a short-lived token at publish time. No stored secrets, and npm generates provenance automatically.

Two structural changes were forced by npm's rules:

  • npm validates the top-level workflow filename, and a package gets exactly one trusted publisher. Beta publishes previously entered through draft.ymlpublish.yml via workflow_call, which would validate as draft.yml. draft.yml now dispatches publish.yml with gh workflow run instead (workflow_dispatch is exempt from the GITHUB_TOKEN no-recursive-workflows rule), so every publish runs with publish.yml as the top-level workflow. workflow_call/NPM_TOKEN inputs are removed.
  • Trusted publishing needs Node ≥ 22.14 and OIDC-aware pnpm. The publish job moves to Node 24 and pnpm 10 (still lockfile v9; publishing must stay on pnpm because of workspace:* deps).

What a reviewer should look at

  • workflows/publish.wac.ts — token steps removed, id-token: write added, workflow_callworkflow_dispatch
  • workflows/draft.wac.tsPublishBetaPackages is now a dispatch job with actions: write
  • .github/workflows/*.yml are generated from the above

Setup required before merge (npmjs.com)

For each of @github-actions-workflow-ts/lib, /cli, /actions: package Settings → Trusted Publisher → GitHub Actions with org emmanuelnk, repo github-actions-workflow-ts, workflow publish.yml, environment blank. Then delete the NPM_TOKEN repo secret.

Test Plan

Verified locally on Node 24 + pnpm 10.34.5 in an isolated clone: install works (dep build scripts blocked by pnpm 10's default, but the build passes — esbuild binaries come via optionalDependencies), pnpm -r publish --dry-run packs all three packages after a version bump, and the packed cli tarball rewrites workspace:* → the real version. The OIDC exchange itself can only be tested by a real run after the npmjs.com config.

🤖 Generated with Claude Code

Replaces NPM_TOKEN auth with npm trusted publishing: the publish job gets
id-token: write and pnpm mints a short-lived token from the runner's OIDC
identity. Requires Node >= 22.14 and a pnpm version with OIDC support, so
the publish job moves to Node 24 and pnpm 10 (same v9 lockfile format).

npm validates the top-level workflow filename against the package's single
trusted publisher, so beta releases can no longer enter via workflow_call
from draft.yml. draft.yml now dispatches publish.yml (workflow_dispatch is
exempt from the GITHUB_TOKEN no-recursive-workflows rule).
@vercel

vercel Bot commented Aug 11, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
github-actions-workflow-ts Ready Ready Preview Aug 11, 2026 8:13pm

@emmanuelnk
emmanuelnk merged commit 10366ad into main Aug 11, 2026
9 checks passed
@emmanuelnk
emmanuelnk deleted the feat/npm-trusted-publishing branch August 11, 2026 20:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant