Repository navigation
ci(publish): name npm-publish as the approval gate for every publish - #7870
michaelwang11394 wants to merge 4 commits into
Conversation
…e-commit code Builds, lifecycle scripts and packing move to a pack job with a read-only token and no secrets. The publish job, which holds the npm token and the write token, checks each tarball's name and version against the release and uploads it with lifecycle scripts off. A version already on npm with other contents fails the first attempt instead of being skipped.
…proves A prerelease tag can come from any prerelease branch, which no PR review covers. Tag-push runs now use the npm-prerelease environment, which requires a maintainer's approval. Merged release PRs keep the npm-publish environment.
jrusso1020
left a comment
There was a problem hiding this comment.
APPROVE @ d2457e0. The code change is correct: tag pushes select npm-prerelease, merged release PRs keep npm-publish, and the new test pins both the expression and that publish is the only job with an environment.
Need ✅ · Size ✅ · Reuse ✅ · Simpler ✅ · Structure ✅ · Risk: low (the security value depends on environment setup, below)
The gate is only as strong as the environment configuration. A tag push runs the workflow file from the tagged commit, so whoever can push a prerelease tag can also edit publish.yml on that commit. That edit could drop environment:, name npm-publish instead, or read the npm credential from another job. Besides the admin steps in the description (required reviewers, prevent self-review, v*-* tags, credential added), the approval only holds if both of these are true:
- The npm credential exists only as an environment secret on
npm-prereleaseandnpm-publish, with no repository- or organization-level secret of the same or any other name that this repo can read. Otherwise any job in an edited workflow can use it without approval. npm-publishrefuses tag refs. Its deployment-branch policy must not admitrefs/tags/*, so an edited workflow on a tag push can't pick the ungated environment.
Worth adding both lines to the setup checklist in the description, and a sentence in release-channels.mdx, so the next person who touches the environments keeps them.
No other findings. Not merging; per the description it waits for the environment to exist.
— Rames
|
Maintainers decided to keep a single publish environment rather than adding Could you drop the environment switch in — Rames |
…ironment npm's trusted publishers are pinned to npm-publish, and that environment now requires a maintainer's approval with self-review prevented. A second environment would fail npm auth, so the workflow keeps npm-publish for every trigger. The docs and test name it as the approval gate.
|
Done in 7ec7e28. The environment switch is gone, so 🤖 Addressed by Claude Code |
jrusso1020
left a comment
There was a problem hiding this comment.
APPROVE @ 7ec7e28. One gated environment for every trigger is simpler than the two-environment split, and it closes the concern from my last review.
Need ✅ · Size ✅ (3 files, +16/−8 vs my last review) · Reuse ✅ (same environment main already uses) · Simpler ✅ (drops the second environment) · Structure ✅ · Risk: low
My earlier conditions, rechecked against the repository settings:
- No ungated environment to fall back to. Every publish now runs in
npm-publish, so there's no second environment for a changed workflow to select.npm-publishhas therequired_reviewersrule (3 reviewers,prevent_self_review: true). None of the repo's other environments holds a secret. - Tags are admitted. On
main, thev0.9.28-alpha.*tag pushes already published throughnpm-publish, so its deployment policy accepts prerelease tags. My old ask thatnpm-publishrefuse tags no longer applies with one environment. - Credential location. No secret named
NPM_TOKENis visible to this repo at environment, repository or organization level. Publishing therefore authenticates through npm trusted publishing. With npm's trusted publishers pinned tonpm-publishas you describe, a job outside that environment can't authenticate. I can't see npm's side from GitHub, so that pin is the one thing I took on trust.
Tests: node --test scripts/publish-workflow.test.mjs passes 15/15 at head. With the publish job's environment changed back to the old two-environment expression, the new test fails (not ok 15), so it pins the gate.
Non-blocking:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}now resolves to nothing. Consider dropping it, so that a token added later at repo or org level doesn't quietly become a second way to authenticate. If a token is ever needed, keep it as an environment secret onnpm-publishonly.- A correction to my #7869 review:
id-token: writeis needed for trusted publishing. Keep it, and ignore that nit.
— Rames
The base branch was changed.
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Automations to automatically generate PRs for you. |
# Conflicts: # .github/workflows/publish.yml # scripts/publish-workflow.test.mjs
jrusso1020
left a comment
There was a problem hiding this comment.
Re-review at d69e48383bf4a39b00345a200c74c688f454de47, a merge of main after #7869 landed.
Verdict: APPROVE. The diff against main is now the three files I approved at 7ec7e28f, and nothing else (+16/−1):
publish.ymlonly adds the comment aboveenvironment: npm-publish.- The
release-channels.mdxtext and the new test are unchanged. publishis still the only job with an environment.
At this head, node --test scripts/publish-workflow.test.mjs passes 15 of 15.
The NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} line is now on main (it came in with #7869), so it's outside this diff. It's still dead under trusted publishing and can go in a follow-up.
Need: yes · Size: ok (3 files, +16/−1) · Reuse: unchanged · Simpler: already minimal · Structure: fine
Risk: low — one environment line and docs; the approval gate's settings are unchanged
— Rames
What
The publish job keeps
environment: npm-publishfor every trigger. A comment, a workflow test and the release docs now state thatnpm-publishis the approval gate. Every publish, stable or prerelease, waits for a maintainer other than the one who started it to approve the run.Stacked on #7869.
Why
Prerelease tags are published from
next,alphaandprerelease/*branches, and no PR review covers those branches. The environment approval is the only review a prerelease gets, so the workflow must not move the publish job to an ungated environment. The test fails if it does.A separate
npm-prereleaseenvironment was considered and dropped. npm's trusted publishers for every package are pinned tonpm-publish, so a job in another environment would fail npm auth.Related work
Stacked on #7869, which moves the build out of the job that holds the npm token.
How
publish.yml: a comment onenvironment: npm-publishsays why every trigger uses it.scripts/publish-workflow.test.mjs: the publish job's environment isnpm-publish, and no other job has an environment.docs/contributing/release-channels.mdx: the stable and alpha flows each say the run waits for approval, and the CI guardrails list it.Test plan
What I measured
node --test scripts/publish-workflow.test.mjs: 15 of 15 pass.npm-publishhas arequired_reviewersrule with three reviewers andprevent_self_review: true.What I did NOT exercise