Skip to content

ci(release): publish prereleases to npm next and as GitHub prereleases - #36

Merged
akosidencio merged 1 commit into
devfrom
ci/release-prerelease-channels
Nov 27, 2026
Merged

akosidencio merged 1 commit into
devfrom
ci/release-prerelease-channels

Conversation

@akosidencio

Copy link
Copy Markdown
Member

Why

release.yml had no notion of a prerelease. A v0.4.0-rc.1 tag would have run npm publish with no --tag:

  • npm 11 refuses that for a prerelease.
  • Older npm tags it latest.
  • The workflow installed npm@latest, which is now npm 12, so the behaviour was not even fixed.

The GitHub release would also have been a regular "latest" release. This was risk #10 in the v0.4.0 gate: "do not push rc tags". Merge this before the RC PR, and before any rc tag.

What

scripts/release/release-plan.js derives the channel from the version alone:

Version npm dist-tag GitHub release
0.4.0 latest latest
0.4.0-rc.N, -beta.N, -alpha.N next prerelease, make_latest: false
anything else refused —

plan job (runs first):

build job: binaries the runner can execute (darwin-arm64, linux-x64, win32-x64) must print the tag's version.

publish job:

  • Checks that all 20 binaries are staged.
  • Passes an explicit --tag and --provenance to every publish. Platform packages go first; the main package goes only after every platform it pins is visible on the registry.
  • Skips versions already published, so the job can be re-run.
  • Afterwards waits up to about 5 minutes for registry lag, then checks the dist-tags. For a prerelease it fails if latest moved, and prints the npm dist-tag add command to restore it.
  • No longer rewrites versions; the tree must already carry them.

Pinned:

  • Every action to a commit SHA.
  • Rust 1.100.0 and Node 24.22.3. Node 24.22.3 bundles npm 11.19.1, which supports trusted publishing, so the npm@latest install is gone.
  • cross to a revision and its aarch64 image to a digest. That image is today's main, which needs glibc ≥ 2.39, the same floor as v0.3.3's arm64 binary.
  • Runner labels to ubuntu-24.04 and windows-2025-vs2026.
  • No build cache in the binary job.

Permissions:

  • Top level is contents: read.
  • Only publish-npm has id-token: write.
  • The GitHub release moves to its own job, the only one with contents: write.

Re-runs and concurrency: artifacts are kept 7 days, and a concurrency group allows one run per tag.

scripts/bump-version.js:

  • Rejects malformed versions.
  • Fixes the Cargo.toml regex. Bumping 0.4.0-rc.1 → 0.4.0 used to leave Cargo at rc.1 while npm moved.
  • Updates the Cargo.lock workspace entries and verifies the result.

CONTRIBUTING: new "Releasing" section, including moving next after a stable release.

Testing

  • 26 node:test cases, run in CI's web job, so the job count stays 13. They cover:
    • stable, rc, beta, alpha, malformed and mismatched versions;
    • publish order, retries, registry lag and the latest-moved check;
    • the bump round trip, the plan CLI outputs and workflow pinning.
  • Mutation checks: dropping --tag, mapping rc to latest, removing the latest-moved check, publishing main before platforms, skipping the Cargo.lock check, and accepting build metadata each fail the tests.
  • actionlint is clean.
  • Dry run with the real npm 11.19.1 against the live registry, on dev + this PR + the RC PR:
    • plan --tag v0.4.0-rc.1 gives next / prerelease.
    • publish --dry-run publishes all six packages "with tag next".
    • A stable copy bumped to 0.4.0 publishes "with tag latest".
    • v0.4.0 on the rc tree, v0.4.0-rc.2, v0.4.0-RC.1 and a tag without v are refused.
    • npm dist-tags are unchanged (latest: 0.3.3, no next).
  • Not run: the workflow itself, which runs only on a tag push.

The release workflow had no notion of a prerelease. A v0.4.0-rc.1 tag
would have run `npm publish` with no --tag. npm 11 refuses that for a
prerelease version; older npm tags it `latest`. The GitHub release
would also have been created as a regular latest release.

scripts/release/release-plan.js now derives the channel from the
version alone:
- 0.4.0 is stable: npm `latest`, GitHub release marked latest.
- -rc.N, -beta.N and -alpha.N are prereleases: npm `next`, GitHub
  prerelease, make_latest false.
- Any other version is refused.

A prerelease also needs docs/releases/v<version>.md, which becomes the
release body.

plan job (runs first):
- Keeps the PR #33 guard and widens it: the tag must match Cargo.toml,
  every Cargo.lock workspace entry, all six npm manifests and the five
  platform pins.

build job:
- Binaries on runnable targets must report the tag's version.

publish job:
- Re-checks the plan and refuses incomplete staged binaries.
- Passes an explicit --tag to every `npm publish`. Platform packages go
  first; the main package goes only once every platform package it pins
  is on the registry.
- Skips versions already published, so a failed run can be re-run.
- Afterwards waits out registry lag and checks that the dist-tag points
  at the version and, for a prerelease, that `latest` did not move.
- No longer rewrites versions; the tree must already carry them.

Pinned:
- Every action to a commit SHA.
- Rust 1.100.0 and Node 24.22.3.
- `npm install -g npm@latest` removed: that is now npm 12. Node 24.22.3
  bundles npm 11.19.1, which supports trusted publishing.
- cross to a revision and its aarch64 image to a digest.
- Runner labels to ubuntu-24.04 and windows-2025-vs2026.
- No build cache in the binary job.

Re-runs and gates:
- Artifacts are kept 7 days instead of 1, so failed jobs can be re-run.
- The registry wait is about 5 minutes.
- The tag must be on main (every earlier tag is).
- setup-node runs on every build runner.

Permissions:
- Top-level permissions are contents: read.
- Only publish-npm has id-token: write.
- The GitHub release moves to its own job, the only one with
  contents: write.

bump-version.js:
- Rejects malformed versions.
- Replaces a prerelease version in Cargo.toml; the old [\d.]+ pattern
  left 0.4.0-rc.1 in place when bumping to 0.4.0.
- Updates the Cargo.lock workspace entries.
- Verifies the result.

Testing:
- 26 node:test cases: stable, rc, beta, alpha, malformed and mismatched
  versions, publish order, dist-tags, retries, registry lag, the
  latest-moved check, the bump round trip, the plan CLI outputs, and workflow
  pinning.
- They run in CI's web job.
@akosidencio
akosidencio merged commit 6037890 into dev Nov 27, 2026
13 checks passed
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.

1 participant