Repository navigation
ci(publish): publish prebuilt tarballs from a job that runs no release-commit code - #7869
Merged
Merged
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.
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Automations to automatically generate PRs for you. |
jrusso1020
approved these changes
Nov 15, 2026
jrusso1020
left a comment
Collaborator
There was a problem hiding this comment.
APPROVE @ fabdfc5. The publish job holding NPM_TOKEN and the write token no longer runs anything from the release commit.
Need ✅ · Size ✅ · Reuse ✅ · Simpler ✅ · Structure ✅ · Risk: low
What I checked in publish:
- Release-commit code. The only checkout is used by git, for the tag. Nothing runs from it: no local action, no
bun/pnpm/node, and no install or build.scripts/publish-workflow.test.mjs"the publish job runs no code from the release commit" enforces this. - Lifecycle scripts.
npm publish <tarball> --ignore-scriptsruns on a prebuilt tarball, so noprepublishOnly/preparehook runs next to the token. .npmrc. "Publish packages" runs inrunner.temp, which has nopackage.jsonabove it, so the only.npmrcnpm reads is the one setup-node writes there. The bundle is extracted intorunner.temp/release-bundlebydownload-artifactv4.3.0. That version includes the artifact path-traversal fix, so a crafted bundle can't overwriterunner.temp/.npmrc.- setup-node cache. None. No
cache:is set, and v4.4.0 doesn't turn caching on by itself (v5 does frompackageManager, so keep this pinned to v4 or setpackage-manager-cache: falsewhen bumping). - Version and channel. These are re-derived from the event, and the channel rules are inlined rather than read from
scripts/validate-release-channel.mjs, so pack-job outputs aren't trusted. - Artifact handoff.
download-artifactwithoutrun-idreads only this run's artifacts, so a concurrent run can't swap the bundle. A fork PR closed event needs a mergedrelease/v*head and gets no secrets anyway. - Name/version guard. Every tarball must parse, match
NPM_PACKAGESexactly once and carry the release version. Any tarball outside the list fails the job. "the workflow publishes exactly the public workspace packages" tiesNPM_PACKAGESto every non-privatepackages/*/package.json, so a package added later fails CI until it's listed. - Action pins. All six are pinned to the SHAs of real tags: checkout v4.4.0, setup-node v4.4.0, upload-artifact v4.6.2, download-artifact v4.3.0, cache v4.3.0, setup-bun v2.2.0.
- Tests.
node --test scripts/publish-workflow.test.mjspasses locally, 14/14.
Non-blocking:
publishkeepsid-token: write, but nothing uses it: there's no--provenanceand nopublishConfig.provenancein any package. Either drop it, or add--provenancetonpm publish, which works with a tarball argument on GitHub-hosted runners and gives the tarballs an attestation. This predates the PR.- On a re-run (
RUN_ATTEMPT > 1), any content mismatch becomes a warning, including the case where attempt 1 itself failed on that mismatch because the version was already there from elsewhere. A re-run then hides the earlier hard error. To narrow this, accept the mismatch only when npm'stime["<version>"]for that package is later than the run's start. - Nit: the
lambda-arm64-ffmpegcheckout doesn't setpersist-credentials: false, unlike the other three jobs. It's a read-only token, so this is only about consistency.
I didn't re-pack 0.9.54 myself to confirm the 15 manifests match npm.
— Rames
3 of 4 tasks
Open
2 of 4 tasks
This branch was successfully deployed
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.
What
The npm publish workflow now builds and packs in one job and publishes in another.
packjob runs everything that comes from the release commit: install, build, Lambda pinning,verify:packed-manifests,pnpm packfor each package,npm packfor the CLI, and the agent plugin build. It has a read-only token and no secrets. It uploads onerelease-bundleartifact.publishjob holdsNPM_TOKEN,id-token: writeand thecontents: writetoken. It no longer installs, builds or runs any repo script. It only runs git (for the stable tag),gh,jq,tarandnpm.npm publish <file> --ignore-scripts, from$RUNNER_TEMPso no project.npmrcapplies.scripts/validate-release-channel.mjsfrom the release commit.Why
The publish step ran
bun install,bun run buildandpnpm publishin the same job that held the npm token. Anyprepare,prepackorprepublishOnlyscript in the tagged commit, or any build step, could read the token or use the write token. The published version also came from eachpackage.jsonwithout being compared to the tag, so a prerelease tag could publish a plainx.y.zthat the real stable release would later skip as "already published".Related work
None open. This builds on #7495 and #7502, which already moved the Lambda zip build out of the publish job and kept the write token out of the checkout.
How
NPM_PACKAGESis a workflow-level list of the 15 published package names, in the old publish order. A test checks it matches every non-private workspace package, with@hyperframes/clipublished ashyperframes.pnpm packwrites the same tarball thatpnpm publishuploaded before:publishConfigapplied andworkspace:ranges replaced.release/vX.Y.ZPR, the exact merge commit, the same tag step.Test plan
What I measured
node --test scripts/publish-workflow.test.mjs scripts/validate-release-channel.test.mjs: 24 of 24 pass. New tests run the real step scripts:--ignore-scripts, skips an identical upload, fails a first attempt when npm already has other contents, and warns on a re-run.NPM_TOKENappears once.Pack packagescommands. Then I ran the publish job'sCheck packed tarballsscript on the 15 real tarballs, and it accepted all of them in publish order.package.jsonfiles are identical, including the renamed CLI. File lists match except for bundler hash names in studio and the CLI, from commits after 0.9.54, and the two Lambda pin files, which only the CI pin steps create.What I did NOT exercise
actionlint. I checked that the YAML parses and that the job graph is right.release-bundleartifact upload and download, with the Lambda video image inside it.