# Releasing (https://kumoba.dev/releasing)

kumoba ships as four crates on crates.io (`kumoba-protocol`, `kumoba-guest`, `kumoba`, `kumobad`), one npm package (`kumoba`) and a GitHub release with host tarballs. They share one version and go out together from one tag, when the release pull request is merged.

## Versioning [#versioning]

- One version for everything. The SDK version tells you which `kumobad` it was tested against, and the `kumobad` version tells you which guest agent its images need.
- Pre-1.0: a minor bump (`0.2.0`) may break the HTTP API, the SDK or the host-guest protocol; a patch bump never does.
- Bumping `VERSION` in `crates/kumoba-protocol/src/lib.rs` is always a minor bump, and the changelog entry says that images must be rebuilt. The worker refuses a guest with another protocol version, so a stale image fails loudly rather than subtly.
- Every pull request that changes behaviour adds a line under `## [Unreleased]` in `CHANGELOG.md`. The release notes are generated from that section, so write for users, not for the diff.

## Cutting a release [#cutting-a-release]

Releases go out through a release pull request. Every push to `main` runs `.github/workflows/release-pr.yml`, which keeps one open pull request, `Release vX.Y.Z`, from the branch `release/next`:

1. Merge pull requests into `main` as usual, each with its changelog line.
2. `scripts/release-pr.sh` runs in three jobs, so that cargo and npm, which run dependency code, never hold a write token. It works out the version with `scripts/next-version.sh`: a minor bump when Unreleased has an entry under Added, Changed, Deprecated or Removed, text outside a heading, or when `VERSION` in `crates/kumoba-protocol/src/lib.rs` changed since the last tag; a patch bump when it has only Fixed and Security entries. It then runs `scripts/prepare-release.sh`, which writes the version into `Cargo.toml`, `Cargo.lock`, `package.json` and `package-lock.json`, rebuilds the live view client, turns the Unreleased section into `## [X.Y.Z] - <date>` with compare links and runs `scripts/release-check.sh`. The date is the day the pull request was last rebuilt, not the day it is merged. A job without a token commits that as `Release vX.Y.Z` on top of `main`; a job with a write token but no build checks it with `scripts/check-release-commit.sh` (one parent, that `main`; only those files, as regular files; the manifests and changelog exactly as `scripts/release-edits.sh` writes them; the lockfiles changed only in the workspace versions), force-pushes it to `release/next`, and creates or updates the pull request with the pull requests merged since the last release and their authors. Pushes made with the workflow's token start no workflows, so it starts `ci.yml` on `release/next` itself. When Unreleased is empty it closes the pull request.
3. To release another version, such as a major bump or a patch release with a minor entry, run the `release-pr` workflow from the Actions tab on `main` with that version. The pull request keeps it until the release or until you close the pull request. The `dry_run` input prints the pull request without pushing anything. The release pull request takes `X.Y.Z` versions only; release a prerelease such as `1.0.0-rc.1` with `scripts/release.sh`.
4. Review the pull request: the version, the notes and CI. CI can't boot macOS guests, so when a change touches macOS sandboxes, first run `scripts/macos-smoke.sh` on an Apple silicon Mac with `kumobad` running and the `macos` image built. When it touches the live view, also open `kumoba desktop <id> --open` on a macOS sandbox and check the picture, typing, a click and the scroll wheel; CI covers the Linux live view only.
5. Merge it. That push to `main` runs `.github/workflows/release.yml`, which releases and then tags the merge commit `vX.Y.Z`. Its publish jobs wait in the `release` environment until a required reviewer approves the deployment on the run page.

`release.yml` runs on every push to `main`, but its first job, `scripts/release-decision.sh`, releases only the merge of the release pull request: the push changed the workspace version and only the files a release changes, `v<version>` is not tagged yet, and the pushed commit belongs to a merged pull request that `github-actions` opened from `release/next` in this repository and built on the `main` it merged into. Other pushes end there; a push that changed the version any other way ends with a warning. GitHub links a merge to its pull request shortly after the push, and the job waits about a minute for that; if a release merge still ends with "not the merge of the release pull request", use "Re-run all jobs" on that run. Pull requests merged while a release runs wait for the next release pull request, which the release opens when it finishes.

When `release/next` was last rebuilt before a later merge to `main`, merging the release pull request does not release, as the reviewed commit is not what `main` holds; wait for the pull request to be rebuilt before merging it. If the workflow can't push `release/next` because a change under `.github/workflows` reached `main` (the workflow's token may not push workflow changes), delete the branch `release/next` by hand, which closes the pull request, and run the `release-pr` workflow again.

1. **check**: `scripts/ci-release.sh` confirms the tag, manifests and changelog agree, runs the Rust lints and unit tests (with `scripts/ci-lint.sh`, which also rebuilds the live view client with `scripts/build-view.sh` and fails when `sdk/typescript/src/view/codec.ts` or `crates/kumoba-view/viewer/view.js` differ from the released commit; the release pull request's job that pushes `release/next` checks those two files only by name, so this is where a changed client is caught before anything is published), `cargo publish --workspace --dry-run` and the SDK typecheck, build and tests, and packs the npm package, which it keeps as the `npm-package` artifact.
2. **assets**: builds `kumoba-<version>-linux-x86_64.tar.zst`, `-linux-arm64.tar.zst` and `-macos-arm64.tar.zst` with `scripts/release-assets.sh`. Linux tarballs carry the patched libkrun and libkrunfw; the macOS tarball expects Homebrew's. The Linux binaries and libkrun are built in the AlmaLinux 8 container of `images/linux-build` (`scripts/build-linux-release.sh`), so they need glibc 2.28, and `scripts/check-glibc.sh` fails the job when a binary in the tarball needs a newer one. It counts every glibc version a binary requires, also the ones the linker marked weak, since whether a linker marks one weak varies. The job then runs `kumobad --version` and `kumoba --version` in that container and fails when `ldd` finds a library missing. The `release-build` job in `ci.yml` does the same for x86_64 on every pull request.
3. **images**: `scripts/release-images.sh` builds the `test` and `default` guest images on Linux x86_64 and arm64 as `kumoba-image-<name>-<version>-<arch>.raw.zst`. macOS uses the arm64 images.
4. **smoke**: `scripts/release-smoke.sh` installs the x86_64 tarball and both images with `scripts/install.sh`, starts `kumobad` with an empty environment and boots each image through the SDK with no options. Nothing is published unless this passes.
5. **publish-crates**: `scripts/publish-crates.sh` publishes the crates in dependency order with a short-lived token from crates.io trusted publishing.
6. **publish-npm**: `scripts/publish-npm.sh` checks the name and version of the tarball from **check** and publishes it to npm through trusted publishing with `--ignore-scripts`, so no package script or dependency runs while the job can publish; npm attaches a provenance attestation for the tarball.
7. **release**: `scripts/release-tag.sh` tags the released commit `vX.Y.Z`, `scripts/publish-release.sh` creates the GitHub release with the changelog section, an install section, the generated contributor notes, the tarballs, the images and `SHA256SUMS`, and the job starts `release-pr.yml` for the changes merged meanwhile. `scripts/install.sh` downloads from the latest release, so users get it from this moment.

Every publish step skips a version the registry already has, so "Re-run failed jobs" on a failed run is safe. The publish jobs run only for a push, and running the workflow by hand from the Actions tab does steps 1 to 4 only, which is the way to test the pipeline, including the installer, without releasing.

### Without the release pull request [#without-the-release-pull-request]

`scripts/release.sh` still cuts a release by hand, on a clean `main` checkout that CI has passed, after the macOS checks above:

```sh
scripts/release.sh 0.2.0
git show --stat HEAD
git push origin main v0.2.0
```

It runs `scripts/prepare-release.sh`, commits `Release v0.2.0` and tags `v0.2.0`, and pushes nothing. Pushing the tag runs `release.yml` as above; the run for the push to `main` sees the tag and ends.

## When something goes wrong [#when-something-goes-wrong]

- A release that must not be used: `cargo yank --version X.Y.Z <crate>` for each crate and `npm deprecate kumoba@X.Y.Z "<reason>"`, then ship a fixed patch release. Nothing is ever unpublished or re-tagged.
- A broken tarball with good packages: fix the script, rerun the workflow. `publish-release.sh` replaces assets on an existing release.
- A merged release that did not release, or failed before anything was published (check, assets, images or smoke): the version stays untagged, so `release.yml` and `release-pr.yml` skip every push to `main` until that changes. When "Re-run failed jobs" fixes it, do that. Otherwise revert the release pull request's merge through a pull request (`git revert -m 1 <merge commit>`, or a plain revert for a squash merge), which puts the version and the Unreleased entries back, and merge the fix; the release pull request is rebuilt with both.
- A release that failed after something was published (a crate or the npm package): never reuse the version for other code. When "Re-run failed jobs" fixes it, do that. Otherwise tag the release merge commit by hand (`git tag -a vX.Y.Z -m "kumoba vX.Y.Z" <merge commit> && git push origin vX.Y.Z`) so the flow moves on, yank or deprecate what must not be used, and merge the fix with a Fixed line; the next release pull request is the patch release. The tag run publishes what is still missing from that commit, so cancel it if that should not go out.
- A tag on the wrong commit that has not been pushed: `git tag -d vX.Y.Z` and `git reset --hard HEAD~1`, then start again.

## Pinned tools [#pinned-tools]

Actions, npm and the image base are pinned, so a new upstream release does not change what a tag builds or publishes. Every action in `.github/workflows/` is pinned to a full commit SHA with its version in a trailing comment (the `cargo-deny` version comes with the `taiki-e/install-action` commit), the image Dockerfiles pin `debian:trixie-slim` and the release build container `almalinux:8.10` by digest, and `publish-npm` installs npm 11.21.3, a version that supports trusted publishing and runs on Node 26. Dependabot (`.github/dependabot.yml`) opens weekly pull requests for new action commits, image digests, crates and SDK dependencies. It does not see the npm version in the `run:` step, the actionlint version in `scripts/install-actionlint.sh` or the Verus release and toolchain in `scripts/install-verus.sh`; bump those by hand. Dependabot keeps `almalinux` on version 8, since a newer one would raise the glibc the Linux release needs, and skips `vstd`, which must move together with the Verus release, so bump it in `Cargo.toml` in the same change. Pin any new action or base image the same way.

## Registry setup [#registry-setup]

Done for kumoba 0.1.0: the four crates and the npm package trust `release.yml` in this repository through OIDC, so releases publish without stored tokens, npm attaches provenance, and nothing needs a manual publish. Repository rulesets stop `v*` tags from being moved or deleted and stop force pushes to or deletion of `main`; `release.yml` creates the tag with the workflow's token. `release-pr.yml` needs "Allow GitHub Actions to create and approve pull requests" on in the repository's Actions settings to open the release pull request. The crates.io, npm and GitHub release jobs run in the `release` environment, which only `main` and `v*` tags can deploy to and which needs a required reviewer (the repository owner) to approve each run, and the crates.io and npm trusted publishers name that environment, so a workflow run from any other branch cannot publish, and a collaborator who merges the release pull request or pushes a `v*` tag cannot publish without that approval. A ruleset requires a pull request and the CI checks for `main`; repository admins can bypass it.

A new crate or npm package added to the release needs the same setup once: publish its first version by hand from the tagged commit, then add the trusted publisher (crates.io: the crate's Settings, Trusted Publishing, GitHub, owner `Parassharmaa`, repository `kumoba`, workflow `release.yml`, environment `release`; npm: the package's Settings, Trusted publishing, GitHub Actions, repository `Parassharmaa/kumoba`, workflow `release.yml`, environment `release`). npm drops a trusted publisher that has not published within two days of being added, so add it right before a release.