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
-
Parse
--version(vX.Y.Zonly). Unless--check, requiregpgon PATH; otherwise refuse before any network access. -
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. -
Pick the release:
releases/tags/<tag>with--version, else the highestvX.Y.Zamong 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.--checkstops here and reports (exit 1 when an update is available); it verifies nothing. -
Tag:
git/refs/tags/<tag>must have exactly one matching ref whose object type istag(annotated), thengit/tags/<sha>must match the ref (sha, tag name), point at a commit and carryverification.signatureandverification.payload. Forgejo's ownverifiedflag is never used. -
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), thengpg --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,EXPKEYSIGorREVKEYSIGstatus line: refused; - exit status 0, exactly one
GOODSIGand exactly oneVALIDSIG; - the
VALIDSIGprimary key fingerprint (last field), or else the signing fingerprint (field 2), must be pinned.
- at least one pinned fingerprint must be in the imported key file (
-
Payload header (
object,type,tag, first blank line ends it) must name the API's commit, typecommitand this tag; if the release names a target commit hash it must be the same commit. -
Assets:
hub-<ver>-<goos>-<goarch>and its.sha256must be listed. The.sha256is 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. -
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 exactlyhub <tag version>. Any failure removes the temp file and replaces nothing. -
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.