Skip to content

ci(publish): publish prebuilt tarballs from a job that runs no release-commit code - #7869

Merged
michaelwang11394 merged 1 commit into
mainfrom
ci-publish-from-packed-tarballs
Nov 15, 2026
Merged

michaelwang11394 merged 1 commit into
mainfrom
ci-publish-from-packed-tarballs

Conversation

@michaelwang11394

Copy link
Copy Markdown
Contributor

What

The npm publish workflow now builds and packs in one job and publishes in another.

  • A new pack job runs everything that comes from the release commit: install, build, Lambda pinning, verify:packed-manifests, pnpm pack for each package, npm pack for the CLI, and the agent plugin build. It has a read-only token and no secrets. It uploads one release-bundle artifact.
  • The publish job holds NPM_TOKEN, id-token: write and the contents: write token. It no longer installs, builds or runs any repo script. It only runs git (for the stable tag), gh, jq, tar and npm.
  • Before uploading, the publish job checks every tarball with inline workflow code. The tarball must be one of the 15 packages this workflow publishes, appear once, and carry exactly the release version from the tag or release branch. A missing or extra tarball fails the job.
  • It publishes each tarball with npm publish <file> --ignore-scripts, from $RUNNER_TEMP so no project .npmrc applies.
  • A version that is already on npm is skipped only when its integrity matches the new tarball, or on a re-run of the same workflow run. On a first attempt with different contents the job fails, because something other than this run published that version.
  • The publish job re-derives the version and checks the release channel inline, instead of trusting the pack job's outputs or running scripts/validate-release-channel.mjs from the release commit.

Why

The publish step ran bun install, bun run build and pnpm publish in the same job that held the npm token. Any prepare, prepack or prepublishOnly script in the tagged commit, or any build step, could read the token or use the write token. The published version also came from each package.json without being compared to the tag, so a prerelease tag could publish a plain x.y.z that 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_PACKAGES is 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/cli published as hyperframes.
  • pnpm pack writes the same tarball that pnpm publish uploaded before: publishConfig applied and workspace: ranges replaced.
  • A Lambda asset that is already attached to the release stays out of the bundle, so the publish job attaches only what the bundle holds. Attaching still fails rather than overwriting.
  • Stable releases keep the same path: a merged release/vX.Y.Z PR, the exact merge commit, the same tag step.

Test plan

  • Unit tests added/updated
  • Manual testing performed
  • Documentation updated (if applicable)
  • Comments follow CONTRIBUTING.md "Comments": they say why, not what, and a bug fix says what the code must do and how to reproduce the bug

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:
    • The tarball check accepts a full set and rejects a stable version under a prerelease tag, a missing package, an extra package, and a duplicate.
    • The publish step publishes with --ignore-scripts, skips an identical upload, fails a first attempt when npm already has other contents, and warns on a re-run.
    • The channel check rejects a stable tag push, a prerelease release PR, and an invalid version.
    • Structural checks: the pack job has no secrets and a read-only token; the publish job runs no bun, pnpm, node or npm install, and NPM_TOKEN appears once.
  • I built main (0.9.54) locally and ran the new Pack packages commands. Then I ran the publish job's Check packed tarballs script on the 15 real tarballs, and it accepted all of them in publish order.
  • I compared those tarballs with the 0.9.54 tarballs on npm. All 15 package.json files 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

  • A real run of the new workflow. Its first real run will be the next release. The Lambda pin and video image steps moved unchanged, but I did not run them with real release assets.
  • actionlint. I checked that the YAML parses and that the job graph is right.
  • The release-bundle artifact upload and download, with the Lambda video image inside it.

…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.
@mintlify

mintlify Bot commented Nov 15, 2026 •

Copy link
Copy Markdown

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated
hyperframes 🟢 Ready View Preview Nov 15, 2026, 10:45 PM

💡 Tip: Enable Automations to automatically generate PRs for you.

@jrusso1020 jrusso1020 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-scripts runs on a prebuilt tarball, so no prepublishOnly/prepare hook runs next to the token.
  • .npmrc. "Publish packages" runs in runner.temp, which has no package.json above it, so the only .npmrc npm reads is the one setup-node writes there. The bundle is extracted into runner.temp/release-bundle by download-artifact v4.3.0. That version includes the artifact path-traversal fix, so a crafted bundle can't overwrite runner.temp/.npmrc.
  • setup-node cache. None. No cache: is set, and v4.4.0 doesn't turn caching on by itself (v5 does from packageManager, so keep this pinned to v4 or set package-manager-cache: false when 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-artifact without run-id reads only this run's artifacts, so a concurrent run can't swap the bundle. A fork PR closed event needs a merged release/v* head and gets no secrets anyway.
  • Name/version guard. Every tarball must parse, match NPM_PACKAGES exactly once and carry the release version. Any tarball outside the list fails the job. "the workflow publishes exactly the public workspace packages" ties NPM_PACKAGES to every non-private packages/*/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.mjs passes locally, 14/14.

Non-blocking:

  1. publish keeps id-token: write, but nothing uses it: there's no --provenance and no publishConfig.provenance in any package. Either drop it, or add --provenance to npm publish, which works with a tarball argument on GitHub-hosted runners and gives the tarballs an attestation. This predates the PR.
  2. 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's time["<version>"] for that package is later than the run's start.
  3. Nit: the lambda-arm64-ffmpeg checkout doesn't set persist-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

@michaelwang11394
michaelwang11394 added this pull request to the merge queue Nov 15, 2026
Merged via the queue into main with commit af0560c Nov 15, 2026
70 checks passed
@michaelwang11394
michaelwang11394 deleted the ci-publish-from-packed-tarballs branch November 15, 2026 23:42

This branch was successfully deployed

1 active deployment
staging - docs — fabdfc5c Deployed Nov 15, 2026 by mintlify[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants