feat(ci): publish to npm via OIDC trusted publishing - #124
Merged
Conversation
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).
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Publishing auths with a long-lived
NPM_TOKENsecret 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: writeand 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:
draft.yml→publish.ymlviaworkflow_call, which would validate asdraft.yml.draft.ymlnow dispatchespublish.ymlwithgh workflow runinstead (workflow_dispatchis exempt from the GITHUB_TOKEN no-recursive-workflows rule), so every publish runs withpublish.ymlas the top-level workflow.workflow_call/NPM_TOKENinputs are removed.workspace:*deps).What a reviewer should look at
workflows/publish.wac.ts— token steps removed,id-token: writeadded,workflow_call→workflow_dispatchworkflows/draft.wac.ts—PublishBetaPackagesis now a dispatch job withactions: write.github/workflows/*.ymlare generated from the aboveSetup required before merge (npmjs.com)
For each of
@github-actions-workflow-ts/lib,/cli,/actions: package Settings → Trusted Publisher → GitHub Actions with orgemmanuelnk, repogithub-actions-workflow-ts, workflowpublish.yml, environment blank. Then delete theNPM_TOKENrepo 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-runpacks all three packages after a version bump, and the packedclitarball rewritesworkspace:*→ the real version. The OIDC exchange itself can only be tested by a real run after the npmjs.com config.🤖 Generated with Claude Code