hub/docs/releasing.md
trvon 0d7a219c5d
Some checks failed
release / build (push) Failing after 2m13s
hub: operator CLI with signed self-update
2026-11-10 20:32:32 -07:00

4.4 KiB

Releasing hub and how hub self-update trusts a release

Cutting a release

scripts/release.sh 0.1.0 --dry-run   # checks only
scripts/release.sh 0.1.0             # signed annotated tag v0.1.0 on main, pushed to the forgejo remote

Preconditions: on a clean main equal to forgejo/main, a signing key configured (user.signingkey or tag.gpgSign), tag not present. The version comes from the tag; there is no file to bump. Only vX.Y.Z tags are offered by hub self-update.

The tag push runs .forgejo/workflows/release.yml (runner label docker, container debian:trixie, one job): go vet, go test, the Python probe tests, static linux-amd64 and darwin-arm64 builds stamped with the tag version, a check that the linux binary prints hub <tag version>, then a draft release, upload of hub-<ver>-<os>-<arch> and its .sha256 (<64 hex> <asset name>), and publish. The workflow is not the trust anchor: the signed tag is. The runner needs network access to the Go module proxy (the go.mod toolchain is newer than the Debian package).

Trust anchor

Pinned signing fingerprints (compiled into the binary, selfupdate.PinnedFingerprints):

Fingerprint
D66F93E5DAD777C373A0CB13083EB1C25C575E81
C1E8284DAE319BA313FCB40038686EA797D7A8A7

Both belong to the release owner. The public keys are embedded as internal/selfupdate/signers.asc; a test checks both fingerprints are in that file. Changing a pin is a reviewed source change and a new release; there is no config switch.

hub self-update, in order

  1. Parse --version (vX.Y.Z only). Unless --check, require gpg on PATH; otherwise refuse before any network access.

  2. Forge address must be https://host (no userinfo, no path). Every request is https. A redirect is followed only to the same host and scheme, at most 3 times; any other redirect is an error.

  3. Pick the release: releases/tags/<tag> with --version, else the highest vX.Y.Z among the newest 20 published releases (drafts and prereleases ignored). Equal to the running version: "up to date". Older than the running version without --version: refused as a downgrade. A dev build (0.0.0-dev...) is older than every release. --check stops here and reports (exit 1 when an update is available); it verifies nothing.

  4. Tag: git/refs/tags/<tag> must have exactly one matching ref whose object type is tag (annotated), then git/tags/<sha> must match the ref (sha, tag name), point at a commit and carry verification.signature and verification.payload. Forgejo's own verified flag is never used.

  5. Signature, with the same procedure as the Security Hub release channel controller (scripts/release_channel.py): a fresh 0700 temporary GNUPGHOME under /tmp (short path for the agent socket), then

    gpg --batch --no-tty --no-autostart --homedir HOME --import HOME/keys.asc
    gpg --batch --no-tty --no-autostart --homedir HOME --list-keys --with-colons --fingerprint
    gpg --batch --no-tty --no-autostart --homedir HOME --status-fd 1 --verify HOME/sig.asc HOME/payload
    gpgconf --homedir HOME --kill all
    
    • at least one pinned fingerprint must be in the imported key file (fpr: lines);
    • any BADSIG, ERRSIG, EXPSIG, EXPKEYSIG or REVKEYSIG status line: refused;
    • exit status 0, exactly one GOODSIG and exactly one VALIDSIG;
    • the VALIDSIG primary key fingerprint (last field), or else the signing fingerprint (field 2), must be pinned.
  6. Payload header (object, type, tag, first blank line ends it) must name the API's commit, type commit and this tag; if the release names a target commit hash it must be the same commit.

  7. Assets: hub-<ver>-<goos>-<goarch> and its .sha256 must be listed. The .sha256 is at most 1 KiB and exactly <64 lowercase hex> <asset name>. The binary is at most 64 MiB (listed size and bytes read). Its sha256 must equal the file's.

  8. The binary is written to a temp file in the running binary's directory (mode 0755) and run as <new> version; the output must be exactly hub <tag version>. Any failure removes the temp file and replaces nothing.

  9. The running binary is kept as <name>.previous (hard link, or copy), then the temp file is renamed over it (atomic). Symlinks to the binary are resolved first.

Rolling back

mv hub.previous hub in the binary's directory, or hub self-update --version vX.Y.Z for any published release.