vole
Site
Clone
Read only, no credentials:
https://rodent.software/vole.git
Write over SSH with a registered key:
git clone ssh://git@rodent.software/vole.git
Self-hosted forge that lives in your Git repo.
Sign release packages and repository metadata
a755e48a42fdbf5da4414169e516980e63a063f6 · Keenan Nemetz · 15d ago · parent 58ac37e0
Sign release packages and repository metadata Sign the RPMs before the yum repository reads them, sign the apt Release and yum repomd metadata, and sign SHA256SUMS for direct downloads. The key arrives as the RELEASE_GPG_KEY repository secret; a pushed tag without it fails, while a local run stays unsigned with a note. Signature time is pinned to the tag commit, or to the key creation time when that is later, so a rebuild with the same key is byte-identical.
RELEASING.md +113−35
| @@ -1,21 +1,21 @@ | |||
| 1 | 1 | # Releasing Vole | |
| 2 | 2 | ||
| 3 | 3 | This maintainer guide describes how Vole's own binaries, packages, package | |
| 4 | repositories, checksums, and SBOM are produced. For creating a release in a | ||
| 5 | repository hosted by Vole, see [Releases](docs/releases.md). For development | ||
| 6 | setup and verification, see [DEVELOPMENT.md](DEVELOPMENT.md). | ||
| 4 | repositories, signatures, checksums, and SBOM are produced. For creating a | ||
| 5 | release in a repository hosted by Vole, see [Releases](docs/releases.md). For | ||
| 6 | development setup and verification, see [DEVELOPMENT.md](DEVELOPMENT.md). | ||
| 7 | 7 | ||
| 8 | 8 | ## How the release is built | |
| 9 | 9 | ||
| 10 | 10 | `.vole/workflows/release.yaml` runs on annotated `v*` tags. It tests and scans | |
| 11 | 11 | the tagged source, cross-compiles Linux binaries for both architectures, builds | |
| 12 | packages with [nfpm](https://nfpm.goreleaser.com), writes the apt and yum | ||
| 13 | repositories those packages need, generates an SBOM, writes `SHA256SUMS`, and | ||
| 14 | attaches the results to the tag's release. | ||
| 12 | packages with [nfpm](https://nfpm.goreleaser.com), signs the RPMs, writes the apt | ||
| 13 | and yum repositories those packages need, signs the repository metadata and the | ||
| 14 | checksum list, generates an SBOM, and attaches the results to the tag's release. | ||
| 15 | 15 | ||
| 16 | 16 | The job requires bridge networking to download Go modules and pinned build | |
| 17 | tools. Cross-compilation means any trusted Linux runner with the required image | ||
| 18 | can produce both architectures. | ||
| 17 | tools, and the `RELEASE_GPG_KEY` repository secret. Cross-compilation means any | ||
| 18 | trusted Linux runner with the required image can produce both architectures. | ||
| 19 | 19 | ||
| 20 | 20 | Reproduce the commands from a tagged checkout: | |
| 21 | 21 | ||
| @@ -25,20 +25,79 @@ go run ./cmd/vole workflow run release | |||
| 25 | 25 | ``` | |
| 26 | 26 | ||
| 27 | 27 | A local workflow run checks the build in the defined container but does not | |
| 28 | publish artifacts. The version comes from | ||
| 29 | `git describe --tags --exact-match`; an untagged checkout stops before building. | ||
| 30 | Build outputs use the tag commit time to support byte-for-byte reproduction. | ||
| 28 | publish artifacts. It reads `RELEASE_GPG_KEY` from the instance like a runner | ||
| 29 | does; when the secret is not available it leaves the tree unsigned and says so. | ||
| 30 | A pushed tag without the secret fails rather than publishing an unsigned | ||
| 31 | release. The version comes from `git describe --tags --exact-match`; an untagged | ||
| 32 | checkout stops before building. Build outputs use the tag commit time to support | ||
| 33 | byte-for-byte reproduction. | ||
| 31 | 34 | ||
| 32 | To build the package repositories from packages you already have: | ||
| 35 | To build and sign the package repositories from packages you already have: | ||
| 33 | 36 | ||
| 34 | 37 | ```sh | |
| 35 | python3 scripts/build-package-repos.py --dist dist --version 0.2.0 \ | ||
| 36 | --epoch "$(git log -1 --format=%ct)" | ||
| 38 | epoch="$(git log -1 --format=%ct)" | ||
| 39 | python3 scripts/sign-release.py packages --dist dist --epoch "$epoch" | ||
| 40 | python3 scripts/build-package-repos.py --dist dist --version 0.2.0 --epoch "$epoch" | ||
| 41 | python3 scripts/sign-release.py repositories --dist dist --epoch "$epoch" | ||
| 42 | ( cd dist && find . -type f ! -name SHA256SUMS ! -name SHA256SUMS.asc \ | ||
| 43 | -printf '%P\0' | sort -z | xargs -0 sha256sum > SHA256SUMS ) | ||
| 44 | python3 scripts/sign-release.py sums --dist dist --epoch "$epoch" | ||
| 37 | 45 | ``` | |
| 38 | 46 | ||
| 39 | The script writes `dist/apt/` and `dist/yum/` beside the packages. It needs | ||
| 40 | `dpkg-scanpackages` from dpkg-dev and `createrepo_c` from createrepo-c, which | ||
| 41 | both workflow images carry. | ||
| 47 | `sign-release.py` reads the armored private key from `RELEASE_GPG_KEY`, or from | ||
| 48 | `--key-file` for a local test. It needs GnuPG and `rpm`/`rpmsign`; | ||
| 49 | `build-package-repos.py` needs `dpkg-scanpackages` from dpkg-dev and | ||
| 50 | `createrepo_c` from createrepo-c. Both workflow images carry them. | ||
| 51 | |||
| 52 | ## The release key | ||
| 53 | |||
| 54 | The private key is a repository secret named `RELEASE_GPG_KEY`. The public half | ||
| 55 | is committed at `packaging/keys/vole-release.asc`; the signing script refuses a | ||
| 56 | secret whose fingerprint does not match that file. That check makes a stale | ||
| 57 | committed key a failure instead of a release that verifies against nothing. | ||
| 58 | |||
| 59 | Create the key once, on a trusted machine: | ||
| 60 | |||
| 61 | ```sh | ||
| 62 | export GNUPGHOME="$(mktemp -d)" | ||
| 63 | chmod 700 "$GNUPGHOME" | ||
| 64 | gpg --batch --passphrase '' --quick-generate-key \ | ||
| 65 | 'Vole Release <release@rodent.software>' rsa4096 sign 5y | ||
| 66 | gpg --batch --armor --export > vole-release.asc | ||
| 67 | gpg --batch --armor --export-secret-keys > vole-release.private.asc | ||
| 68 | gpg --list-keys --with-fingerprint | ||
| 69 | ``` | ||
| 70 | |||
| 71 | Store the private key on the instance, where a job reads it through the secret | ||
| 72 | named in its workflow: | ||
| 73 | |||
| 74 | ```sh | ||
| 75 | vole secret set vole RELEASE_GPG_KEY < vole-release.private.asc | ||
| 76 | ``` | ||
| 77 | |||
| 78 | Keep an offline copy of `vole-release.private.asc`; the instance is a backup too, | ||
| 79 | but a single copy is not a backup. Remove the temporary file and GnuPG home | ||
| 80 | afterwards, then commit the public half: | ||
| 81 | |||
| 82 | ```sh | ||
| 83 | shred -u vole-release.private.asc | ||
| 84 | rm -rf "$GNUPGHOME" | ||
| 85 | install -D -m 0644 vole-release.asc packaging/keys/vole-release.asc | ||
| 86 | ``` | ||
| 87 | |||
| 88 | The key has no passphrase. The secret store is the only protection a build job | ||
| 89 | can use, and a passphrase stored in the same instance would be delivered to the | ||
| 90 | same job, so it would protect nothing against a compromised runner or instance. | ||
| 91 | A passphrase would only help an offline copy, so protect the backup instead. | ||
| 92 | Anyone who can control a trusted runner or read this repository's secrets can | ||
| 93 | sign a release; that is the same trust the rest of CI already requires. | ||
| 94 | |||
| 95 | Rotation is a change of its own: generate a new key, commit its public half in | ||
| 96 | the same change that replaces the secret, and tell clients to replace their | ||
| 97 | keyring. A release rebuilt from an old tag after a rotation carries the new | ||
| 98 | signature, not the old one. The key recipe above expires after five years; sign | ||
| 99 | before then, and rotate before expiry. An expired key fails in the signing | ||
| 100 | script rather than producing a release that clients reject. | ||
| 42 | 101 | ||
| 43 | 102 | ## Release contents and SBOM | |
| 44 | 103 | ||
| @@ -47,11 +106,18 @@ A Vole release includes: | |||
| 47 | 106 | - `vole-linux-amd64` and `vole-linux-arm64`; | |
| 48 | 107 | - Debian and RPM packages for both architectures, at the release root; | |
| 49 | 108 | - `apt/` — a flat Debian repository: the packages, `Packages`, | |
| 50 | `Packages.gz`, and `Release` with checksums of both; | ||
| 51 | - `yum/` — an RPM repository: the packages and `repodata/`, including | ||
| 52 | `repomd.xml`; | ||
| 109 | `Packages.gz`, `Release`, `InRelease`, and `Release.gpg`; | ||
| 110 | - `apt/vole.gpg` — the public key as a binary keyring for `signed-by=`; | ||
| 111 | - `yum/` — an RPM repository: the packages, `repodata/`, and | ||
| 112 | `repodata/repomd.xml.asc`; | ||
| 113 | - `yum/RPM-GPG-KEY-vole` — the public key for `rpm --import`; | ||
| 114 | - `vole-release-key.asc` and `vole-release-key.fingerprint` at the release root; | ||
| 53 | 115 | - `vole-<version>.sbom.cdx.json` in CycloneDX JSON; | |
| 54 | - `SHA256SUMS` covering every attached file, including both repository trees. | ||
| 116 | - `SHA256SUMS` and its detached signature `SHA256SUMS.asc`. | ||
| 117 | |||
| 118 | `SHA256SUMS` covers every other attached file, including both repository trees, | ||
| 119 | the public key, and the signatures. It cannot cover its own signature, so | ||
| 120 | `SHA256SUMS.asc` is written after the list and excluded from it. | ||
| 55 | 121 | ||
| 56 | 122 | The SBOM lists linked Go modules, their versions and `go.sum` hashes, the Go | |
| 57 | 123 | toolchain, and detected license evidence. One SBOM covers both architectures | |
| @@ -66,11 +132,21 @@ go run github.com/CycloneDX/cyclonedx-gomod/cmd/cyclonedx-gomod@v1.9.0 \ | |||
| 66 | 132 | app -json -noserial -std -licenses -main cmd/vole -output SBOM.cdx.json . | |
| 67 | 133 | ``` | |
| 68 | 134 | ||
| 69 | The release workflow replaces the tool's wall-clock timestamp with the tag | ||
| 70 | commit time so rebuilding one tag produces the same SBOM. The repository | ||
| 71 | metadata is pinned the same way: `Release`, `Packages.gz`, and `repomd.xml` | ||
| 72 | carry the tag commit time, and the copied packages get that mtime so | ||
| 73 | createrepo_c records it as each package's file time. | ||
| 135 | ## Reproducibility | ||
| 136 | |||
| 137 | The release workflow replaces the SBOM tool's wall-clock timestamp with the tag | ||
| 138 | commit time. The repository metadata is pinned the same way: `Release`, | ||
| 139 | `Packages.gz`, and `repomd.xml` carry the tag commit time, and the copied | ||
| 140 | packages get that mtime so createrepo_c records it as each package's file time. | ||
| 141 | |||
| 142 | Signatures are pinned too, as far as the tools allow. GnuPG and `rpmsign` are | ||
| 143 | given the tag commit time through `--faked-system-time` (for `rpmsign`, through | ||
| 144 | its `%_gpg_sign_cmd_extra_args` macro), so rebuilding one tag with the same key | ||
| 145 | produces the same signed files. GnuPG refuses a signature time before the key | ||
| 146 | was created, so the time used is the later of the tag commit time and the key's | ||
| 147 | creation time. The first releases signed by a fresh key therefore carry the key | ||
| 148 | creation time, not an earlier commit time. A key that has expired at the signing | ||
| 149 | time is an error. | ||
| 74 | 150 | ||
| 75 | 151 | ## Publish the package repositories | |
| 76 | 152 | ||
| @@ -89,21 +165,23 @@ release to change. Clients then use: | |||
| 89 | 165 | ```text | |
| 90 | 166 | https://rodent.software/vole/channels/stable/apt | |
| 91 | 167 | https://rodent.software/vole/channels/stable/yum | |
| 168 | https://rodent.software/vole/channels/stable/vole-release-key.asc | ||
| 92 | 169 | ``` | |
| 93 | 170 | ||
| 94 | Vole does not sign release artifacts, so these are unsigned repositories. The | ||
| 95 | `Release` and `repomd.xml` checksums detect a corrupted download, and HTTPS | ||
| 96 | authenticates the host, but neither proves who built a package. Signing the | ||
| 97 | repositories and packages is tracked in | ||
| 98 | [the signing issue](https://rodent.software/vole/issues/01M7R3T8991225YWK3SP88NS99). | ||
| 171 | Apt verifies `InRelease` (or `Release` plus `Release.gpg`) and the hashes in it. | ||
| 172 | Dnf verifies `repomd.xml.asc` and, with `gpgcheck=1`, each RPM. The public key is | ||
| 173 | served from the same channel for convenience; compare its fingerprint with the | ||
| 174 | committed key at `packaging/keys/vole-release.asc` before trusting it. | ||
| 99 | 175 | ||
| 100 | 176 | ## Package verification in CI | |
| 101 | 177 | ||
| 102 | 178 | `.vole/workflows/verify.yaml` builds and packages one architecture on every | |
| 103 | branch push using the same `packaging/nfpm.yaml`, then builds the apt and yum | ||
| 104 | metadata from those packages. Definition, path, metadata, and unit errors | ||
| 105 | therefore fail before a release tag. `scripts/check-deploy.py` also renders and | ||
| 106 | validates the cloud-init deployment files. | ||
| 179 | branch push using the same `packaging/nfpm.yaml`, builds the apt and yum | ||
| 180 | metadata from those packages, signs them with a throwaway key generated inside | ||
| 181 | the job, and verifies the signatures with the exported public key. Definition, | ||
| 182 | path, metadata, signature, and unit errors therefore fail before a release tag. | ||
| 183 | `scripts/check-deploy.py` also renders and validates the cloud-init deployment | ||
| 184 | files. | ||
| 107 | 185 | ||
| 108 | 186 | See [Packages and upgrades](docs/packaging.md) for the paths and systemd units | |
| 109 | 187 | the packages install, and [Install](docs/install.md#install-from-the-package-repository) | |