feat(release): migrate npm publication to Trusted Publishing/OIDC (Beta.2 slice of #1187) - #1293
Merged
Merged
Conversation
B2.12) Remove the long-lived NPM_TOKEN/.npmrc auth path from autoflow-release.yml and gate npm publication capability on the GitHub Actions OIDC lane instead of token env vars. The release job pins an explicit npm CLI floor (npm@^11.5.1, verified at runtime) because Node 22's bundled npm predates native OIDC support. Publish keeps --provenance in the Actions lane. The no-token shape is mechanically enforced: pr-ci-workflow.test.ts fails closed on any NPM_TOKEN/NODE_AUTH_TOKEN/_authToken reference in the release workflow and requires id-token: write plus the npm floor step before publish. npm-side trusted-publisher registration for the five @OpenElement packages is a maintainer web precondition; see docs/runbooks/npm-trusted-publishing.md. Beta.2 slice of #1187 (B2.12 on #1288).
Deploying openelement with
|
| Latest commit: |
835961e
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://33c11d5a.lessjs.pages.dev |
| Branch Preview URL: | https://kimi-v044-b212-npm-trusted-p.lessjs.pages.dev |
10 tasks
Contributor
|
APIError: Insufficient Balance |
5 tasks
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.
Beta.2 slice of #1187 (tracked as B2.12 on stage issue #1288; umbrella #1155; ADR-0151). NOT closing #1187 — the machine-readable closure-evidence gate (PR #1191 lineage) remains Beta.3 scope.
Problem
npm publication authenticated with a long-lived
NPM_TOKENwritten to~/.npmrcand passed asNODE_AUTH_TOKEN/NPM_TOKENenv inautoflow-release.yml. Policy (SECURITY.md,docs/governance/RELEASE_POLICY.md) already declares Trusted Publishing/OIDC as the only authorized publication path; the implementation lagged the policy.Owner
B2.12 implementer slice (kimi), under Beta.2 stage #1288.
Before
autoflow-release.yml: "Configure npm auth" step wrote//registry.npmjs.org/:_authToken=${NPM_TOKEN}to$HOME/.npmrc; publish step exportedNODE_AUTH_TOKEN/NPM_TOKENfromsecrets.NPM_TOKEN.tools/autoflow/release.tscanPublishNpm()returned true whenNPM_TOKEN/NODE_AUTH_TOKENwas set — any environment holding the token (including a local machine) could publish.id-token: write(already granted).After
.npmrcauth anywhere in the release workflow.id-token: write(already present) is the only npm credential.npm install -g "npm@^11.5.1"+ a runtime>=11.5.1assertion, running before the publish step.registry-url: 'https://registry.npmjs.org'kept (registry/provenance config, not auth).--provenancestays explicit intools/publish-npm.tsfor the Actions lane.canPublishNpm()now returns true only whenGITHUB_ACTIONS === 'true'— publication capability exists only in the hosted OIDC lane; local/manual runs never publish, even if a legacy token variable is set.tools/autoflow/__tests__/pr-ci-workflow.test.tsfails closed on anyNPM_TOKEN/NODE_AUTH_TOKEN/_authTokenreference inautoflow-release.yml, requiresid-token: write, the pinned npm floor, upgrade-before-publish ordering, and a token-free publish-step env.Why not second owner
Single bounded slice per the Beta.2 per-slice completion semantics on #1288; the OIDC migration is one coherent change (workflow + plan gate + tests + runbook) and the npm-side registration is a maintainer web action, not repo work.
Evidence (all local, allowed; no real publish dispatched)
B2.12 (#1187)workflow test failed onNPM_TOKENbefore the workflow edit; the three updated plan tests failed against the oldcanPublishNpm— exact failing assertions recorded.deno test … tools/autoflow/ tools/publish-npm.test.ts→ 148 passed, 0 failed.deno task pack:dry-run→ exit 0 (5 tarballs, 0.44.0-beta.1).deno task package-artifacts:check→ exit 0 (5 packages).deno task publish:npm:dry-run→ exit 0 (real npm CLI dry-run path, registry queried, no auth material present).deno task workflow:check-slimming,actions:check-pins,docs:truth,release:state-machine:check,docs:check-role-neutral,freeze:semantics:check→ all pass.autoflow:publish-existing --dry-runlocally stops at the mandatory--pr-ciexact-SHA evidence requirement (fail-closed by design); the hosteddry_run: truedispatch remains the full rehearsal path post-merge.Scope
Touched:
.github/workflows/autoflow-release.yml,tools/autoflow/release.ts(canPublishNpm),tools/publish-npm.ts(comment only), tests (pr-ci-workflow.test.ts,policy.test.ts,release.test.ts),docs/adr/ADR-0108(supersession note), newdocs/runbooks/npm-trusted-publishing.md. Closure-evidence semantics untouched (Beta.3). Historicaldocs/release/v0.41.0-alpha.1-plan.mdleft as dated history.Risk
Real publishes fail until the npm-side registration below is complete for all five packages — this is loud in the workflow itself (comments on
id-token: writeand the publish step) and intentional: there is no token fallback.Maintainer runbook (npm-side precondition — verbatim from
docs/runbooks/npm-trusted-publishing.md)For each of the five packages —
@openelement/element,@openelement/app,@openelement/adapter-vite,@openelement/create,@openelement/ui— register this exact trusted publisher on npmjs.com:open-elementopenelementautoflow-release.ymlSteps (per package):
@openelementscope.open-element, Repositoryopenelement, Workflow filenameautoflow-release.yml(filename only, no path prefix), Environment empty.Verification: dispatch
autoflow-release.ymlwithdry_run: truefirst; the first real publish must show the Trusted Publishing provenance attestation on each package page. After the first successful trusted publish, theNPM_TOKENrepository secret can be deleted from GitHub — nothing references it.