Release signing: GPG for the tag and tarball, SSH for the commit

Corrects the signing scheme. The release itself — the annotated tag and a
detached signature over the tarball — is GPG-signed; the release commit is
SSH-signed. Because the GPG key lives on a laptop and the build runs on the
build host, the single script becomes three stages split across two machines:

  prepare <ver>  build host: bump, build, meson dist, SSH-signed commit
  sign    <ver>  laptop:     GPG-sign the tarball and the tag
  publish <ver>  laptop:     Gitea release, AUR, Nostr

The GPG key never touches the build host, and only dist/ travels: the laptop
pulls it over SSH. The two signing formats are set per git command
(-c gpg.format=ssh|openpgp), so neither depends on a machine's global config.

- release.sh: prepare/sign/publish subcommands; SSH commit, GPG tag + detached
  tarball signature; REGENT_SSH_SIGNING_KEY / REGENT_GPG_KEY; a release.env
  handoff that pins the tagged commit; optional dist/ pull.
- AUR regent: the .asc in source and validpgpkeys pinned to _fingerprint.
- .ngit/release.yaml: the .asc and an exported public key, replacing the SSH
  .sig and allowed_signers.
- README, doc/dev/releasing.md, AGENTS.md updated for the split.
This commit is contained in:
raucao committed 2026-11-30 00:28:52 +04:00
1 parent ba3d07d7d7
commit 3cb7cb617f
6 files changed
+447 -270

No files matched your search

+4 -3
View File
@@ -27,13 +27,14 @@ publication:
- https://blossom.kosmos.org
assets:
# The files are produced by build-aux/release.sh in dist/ and expand `{version}`
# to the release version (for example 1.0.0-beta.1).
# to the release version (for example 1.0.0-beta.1). The tarball carries a GPG
# detached signature and the public key that verifies it.
- file: dist/regent-{version}.tar.xz
filename: regent-{version}.tar.xz
platform_agnostic: true
- file: dist/regent-{version}.tar.xz.sha256sum
platform_agnostic: true
- file: dist/regent-{version}.tar.xz.sig
- file: dist/regent-{version}.tar.xz.asc
platform_agnostic: true
- file: dist/allowed_signers
- file: dist/regent-signing-key.asc
platform_agnostic: true
+21 -16
View File
@@ -1108,32 +1108,37 @@ the UI is tested. `build-aux/deploy-dev.sh` runs on the build host,
## Releases
- **One entry point, run on the build host: `build-aux/release.sh <version>`.** It
bumps the version, builds and signs the tarball, tags it, and publishes to
Gitea (`gt release create`), the AUR, and Nostr (`ngit release publish`). Every
outward-facing step is skippable (`--no-push`, `--no-release`, `--no-aur`,
`--no-nostr`) so a build can be prepared and reviewed before it goes anywhere.
- **Signing is SSH-only** (`git -c gpg.format=ssh -c user.signingkey=…`): the
annotated tag, and an `ssh-keygen -Y sign` detached signature over the tarball.
No GPG anywhere. That keeps the key on a laptop — run the script under `ssh -A`
and the agent supplies the signature, so the key material never lands on the
build host. The script proves it can sign before writing anything.
- **Three stages, split across two machines:
`build-aux/release.sh prepare|sign|publish <version>`.** The build host runs
`prepare` (bump, build, `meson dist`, and an **SSH-signed** release commit);
the laptop runs `sign` (**GPG**: the tag and a detached tarball signature) and
`publish` (Gitea via `gt release create`, the AUR, Nostr via
`ngit release publish`).
- **The commit is SSH-signed, the release is GPG-signed** — that is the point of
the split: the GPG key stays on the laptop and the build host never needs it.
The two formats are set per git command (`-c gpg.format=ssh|openpgp`), so
neither depends on the machine's global config. `prepare` proves it can
SSH-sign before it writes anything.
- **The release commit is cut before `meson dist`** (the tarball is built from it
and the GPG-signed tag points at it); `sign` refuses unless `HEAD` is the commit
`prepare` recorded in `dist/release.env`, so the tag can never point at a
different tree than the tarball.
- **Only `dist/` travels between the machines.** The laptop pulls it from the
build host over SSH (`REGENT_BUILD_HOST`), so nothing has to be sent back.
- **The version exists in three dialects, derived in exactly one place**
(`release.sh`), because AppStream *and* pacman sort a `-`/`.`-separated
pre-release **above** the final release: `1.0.0-beta.1`
(tag/Cargo/meson/tarball/changelog), `1.0.0~beta.1` (metainfo), `1.0.0beta1`
(AUR `pkgver`). Do not "simplify" one of them — `appstreamcli vercmp` and
`vercmp` both disagree with the semver spelling.
- **The release commit and its tag are cut before `meson dist`**, because the
tarball is built from that commit and the tag has to point at it. Re-signing the
commit afterwards would change its hash and invalidate the tarball's provenance.
- **Release notes live only in `CHANGELOG.md`.** The metainfo `<releases>` block
is generated from it by `build-aux/gen-metainfo-releases.py` (between the
`releases:begin`/`releases:end` markers); never hand-edit the block.
- **The AUR recipes are `build-aux/aur/{regent,regent-git}`** — the stable
tarball package and the VCS one. `release.sh` fills `pkgver`/`_tag`/sha256 and
pushes to `aur.archlinux.org`; the in-repo copy is updated in a post-release
commit, because the sha cannot exist before the tarball does.
tarball package and the VCS one. `publish` fills `pkgver`/`_tag`, the real
sha256, and the signing fingerprint (`validpgpkeys`, with the `.asc` in
`source`), then pushes to `aur.archlinux.org`; the in-repo copy is updated in a
post-release commit, because the sha cannot exist before the tarball does.
`build-aux/regent-dev/` is the *working-tree* package the dev deploy's `--pkg`
builds, not an AUR one.
- **Nostr is a mirror.** `.ngit/release.yaml` publishes the same tarball to
+7 -5
View File
@@ -37,16 +37,18 @@ Otherwise build it from source — see [Development](doc/dev/development.md).
### Verifying a release
Every release carries a SHA-256 checksum and an SSH signature, and its git tag is
signed too. Download `regent-<version>.tar.xz` together with its `.sha256sum`,
`.sig` and `allowed_signers` files, then:
Every release carries a SHA-256 checksum and a GPG signature, and its git tag is
signed with the same key. Download `regent-<version>.tar.xz` together with its
`.sha256sum`, `.asc` and `regent-signing-key.asc` files, then:
```sh
sha256sum -c regent-<version>.tar.xz.sha256sum
ssh-keygen -Y verify -f allowed_signers -I raucao@kosmos.org \
-n file -s regent-<version>.tar.xz.sig < regent-<version>.tar.xz
gpg --import regent-signing-key.asc
gpg --verify regent-<version>.tar.xz.asc regent-<version>.tar.xz
```
The same key fingerprint is pinned in the AUR package's `validpgpkeys`.
## Repositories & Contributions
The upstream repository is available on both Gitea and ngit (git over Nostr), and
+12 -7
View File
@@ -1,22 +1,27 @@
# Maintainer: Râu Cao <raucao@kosmos.org>
#
# Stable package: builds the tarball attached to a Gitea release. The AUR copy
# always carries a real sha256 — build-aux/release.sh writes it before pushing.
# `_tag` is the upstream version; `pkgver` drops the dot in a pre-release suffix
# because pacman orders `1.0.0beta1` below `1.0.0`, while `1.0.0beta.1` would be
# seen as newer (see build-aux/release.sh's arch_version()).
# Stable package: builds the tarball attached to a Gitea release and checks its
# GPG signature against `_fingerprint`. The AUR copy always carries the real
# sha256 for the tarball and the real fingerprint — build-aux/release.sh writes
# both before pushing. `_tag` is the upstream version; `pkgver` drops the dot in
# a pre-release suffix because pacman orders `1.0.0beta1` below `1.0.0`, while
# `1.0.0beta.1` would be seen as newer (see build-aux/release.sh's arch_version).
pkgname=regent
pkgver=0.1.0
pkgrel=1
_tag=0.1.0
_fingerprint=0000000000000000000000000000000000000000
pkgdesc="Remote signer for Nostr (NIP-46)"
arch=('x86_64')
url="https://gitea.kosmos.org/raucao/regent"
license=('Unlicense')
depends=('gtk4' 'libadwaita' 'glib2' 'glibc' 'gcc-libs')
makedepends=('cargo' 'meson' 'blueprint-compiler')
source=("$pkgname-$_tag.tar.xz::https://gitea.kosmos.org/raucao/regent/releases/download/v$_tag/$pkgname-$_tag.tar.xz")
sha256sums=('SKIP') # placeholder; build-aux/release.sh fills in the real hash
_release="https://gitea.kosmos.org/raucao/regent/releases/download/v$_tag"
source=("$pkgname-$_tag.tar.xz::$_release/$pkgname-$_tag.tar.xz"
"$pkgname-$_tag.tar.xz.asc::$_release/$pkgname-$_tag.tar.xz.asc")
sha256sums=('SKIP' 'SKIP') # the tarball's hash is filled in by build-aux/release.sh
validpgpkeys=("$_fingerprint")
prepare() {
cd "$pkgname-$_tag"
+335 -183
View File
@@ -1,40 +1,45 @@
#!/usr/bin/env bash
# Cut a Regent release: bump the version, build and sign the distribution
# tarball, tag it, and publish it to Gitea, the AUR and Nostr.
# Cut a Regent release. Three stages, because the release is signed with GPG and
# the GPG key lives on a laptop while the build runs on the build host:
#
# Signing is SSH-only (git's `gpg.format=ssh`): the annotated tag and a detached
# signature over the tarball are made with an SSH key, so the key can stay on
# your laptop. Forward your agent for the session and run this on the build host:
# prepare <version> build host: bump, build, commit (SSH), make the tarball
# sign <version> laptop: GPG-sign the tag and the tarball
# publish <version> laptop: Gitea release, AUR, Nostr
#
# ssh -A user@build-host
# build-aux/release.sh 1.0.0-beta.1
# The release commit is signed with **SSH** (`gpg.format=ssh`); the tag and the
# detached tarball signature are **GPG**. The two formats are set per git
# command, so neither depends on the machine's global config.
#
# The key comes from REGENT_SIGNING_KEY, else `git config user.signingkey`, else
# ~/.ssh/id_ed25519.pub. It is proven to work (the key is present, or an agent
# holds it) before anything is written, so a missing key fails up front.
# Typical run:
#
# The run is linear and stops at the first failure. Every outward-facing step
# can be turned off, so a build can be prepared and reviewed before it is
# published anywhere:
# build-host$ build-aux/release.sh prepare 1.0.0-beta.1
# laptop$ build-aux/release.sh sign 1.0.0-beta.1
# laptop$ build-aux/release.sh publish 1.0.0-beta.1
#
# --draft open the Gitea release as a draft instead of publishing it
# --no-push do not push commits or tags to origin/nostr
# --no-release do not create the Gitea release
# --no-aur do not update the AUR packages
# --no-nostr do not publish the Nostr release (ngit)
# `sign` pulls dist/ from the build host over SSH when it is not there yet, so
# only the artifacts travel (build host -> laptop); nothing needs to come back.
#
# `--no-push --no-release --no-aur --no-nostr` builds, commits, tags and signs
# locally, then stops. Undo that with
# `git reset --soft HEAD~1 && git tag -d vX.Y.Z`.
# Options:
# --draft publish: open the Gitea release as a draft
# --no-push prepare/publish: do not push commits or tags
# --no-aur publish: do not update the AUR
# --no-nostr publish: do not publish the Nostr release (ngit)
# --no-pull sign: fail instead of pulling dist/ from the build host
#
# Environment:
# REGENT_REMOTE, REGENT_NOSTR_REMOTE remote names (origin, nostr)
# REGENT_AUR_REGENT, REGENT_AUR_GIT AUR clone URLs
# REGENT_SIGNING_KEY SSH public key used to sign
# REGENT_BUILD_DIR build directory (default: _build)
# REGENT_SSH_SIGNING_KEY SSH public key for the release commit (prepare)
# REGENT_GPG_KEY GPG key id/fingerprint for signing (sign, publish)
# REGENT_BUILD_HOST ssh target to pull dist/ from (sign)
# REGENT_REPO_PATH repo path on the build host (default: ~/src/regent)
# REGENT_REMOTE git remote (default: origin)
# REGENT_NOSTR_REMOTE Nostr git remote (default: nostr)
# REGENT_AUR_REGENT, REGENT_AUR_GIT AUR clone URLs
# REGENT_MESON_DIST_ARGS extra args for `meson dist` (prepare)
# REGENT_BUILD_DIR build directory (default: _build)
set -euo pipefail
log() { printf 'release: %s\n' "$*" >&2; }
warn() { printf 'release: warning: %s\n' "$*" >&2; }
die() { printf 'release: error: %s\n' "$*" >&2; exit 1; }
hdr() { printf '\n\033[1m== %s\033[0m\n' "$*" >&2; }
usage() { awk 'NR>1 && /^#/ {sub(/^# ?/,""); print} NR>1 && !/^#/ {exit}' "${BASH_SOURCE[0]}"; }
@@ -49,19 +54,27 @@ AUR_REGENT=${REGENT_AUR_REGENT:-ssh://aur@aur.archlinux.org/regent.git}
AUR_GIT=${REGENT_AUR_GIT:-ssh://aur@aur.archlinux.org/regent-git.git}
BUILD_DIR=${REGENT_BUILD_DIR:-_build}
DIST=dist
AUR_TMP=
version=
draft=no push=yes release=yes aur=yes nostr=yes
# --- arguments ---------------------------------------------------------------
stage=${1:-}
case "$stage" in
prepare|sign|publish) shift ;;
-h|--help|'') usage; [ -n "$stage" ] && exit 0 || exit 2 ;;
*) die "unknown stage: $stage (expected prepare, sign or publish; try --help)" ;;
esac
version= draft=no push=yes aur=yes nostr=yes pull=yes
while [ $# -gt 0 ]; do
case "$1" in
-h|--help) usage; exit 0 ;;
--draft) draft=yes ;;
--no-push) push=no ;;
--no-release) release=no ;;
--no-aur) aur=no ;;
--no-nostr) nostr=no ;;
-*) die "unknown option: $1 (try --help)" ;;
*) [ -z "$version" ] || die "unexpected argument: $1"; version=$1 ;;
--draft) draft=yes ;;
--no-push) push=no ;;
--no-aur) aur=no ;;
--no-nostr) nostr=no ;;
--no-pull) pull=no ;;
-*) die "unknown option: $1 (try --help)" ;;
*) [ -z "$version" ] || die "unexpected argument: $1"; version=$1 ;;
esac
shift
done
@@ -71,10 +84,12 @@ done
tag="v$version"
case "$version" in *-*) prerelease=yes ;; *) prerelease=no ;; esac
# The three version dialects. This is the one place they are derived:
# $version tag, Cargo/meson, tarball name, changelog heading
# $APPSTREAM metainfo (a '-' separator sorts *above* the final release)
# $PKGVER AUR pkgver (pacman wants the dot dropped as well)
# The three version dialects, derived in one place. AppStream *and* pacman sort
# a '-'-/'.'-separated pre-release above the final release, so each needs its own
# spelling:
# $version tag, Cargo/meson, tarball name, changelog heading
# $APPSTREAM metainfo (tilde fixes the ordering)
# $PKGVER AUR pkgver (pacman wants the dot dropped too)
appstream_version() { printf '%s' "${1/-/\~}"; }
arch_version() {
local core=${1%%-*} pre
@@ -85,58 +100,116 @@ arch_version() {
APPSTREAM=$(appstream_version "$version")
PKGVER=$(arch_version "$version")
hdr "preflight"
for tool in git meson appstreamcli python3 ssh-keygen sha256sum; do
command -v "$tool" >/dev/null || die "$tool not found"
done
[ "$release" = no ] || command -v gt >/dev/null || die "gt not found (or pass --no-release)"
[ "$aur" = no ] || command -v makepkg >/dev/null || die "makepkg not found (or pass --no-aur)"
[ "$nostr" = no ] || command -v ngit >/dev/null || die "ngit not found (or pass --no-nostr)"
[ "$release" = no ] || [ "$push" = yes ] \
|| die "--no-push needs --no-release (the release needs its tag on the server)"
# --- shared helpers ----------------------------------------------------------
branch=$(git symbolic-ref --short -q HEAD || true)
[ "$branch" = main ] || die "not on main (on '${branch:-a detached HEAD}')"
git diff --quiet && git diff --cached --quiet || die "the working tree is dirty"
git fetch --quiet "$REMOTE"
[ "$(git rev-parse HEAD)" = "$(git rev-parse "$REMOTE/main")" ] \
|| die "main is not in sync with $REMOTE/main"
git rev-parse -q --verify "refs/tags/$tag" >/dev/null && die "tag $tag already exists locally"
git ls-remote --exit-code --tags "$REMOTE" "refs/tags/$tag" >/dev/null 2>&1 \
&& die "tag $tag already exists on $REMOTE"
require_tools() { for t in "$@"; do command -v "$t" >/dev/null || die "$t not found"; done; }
env_value() { [ -f "$DIST/release.env" ] && sed -n "s/^$1=//p" "$DIST/release.env" | head -1 || true; }
cur_meson=$(sed -n "s/.*version: '\(.*\)',.*/\1/p" meson.build | head -1)
cur_cargo=$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -1)
[ -n "$cur_meson" ] || die "could not read the version from meson.build"
[ "$cur_meson" = "$cur_cargo" ] \
|| die "meson.build ($cur_meson) and Cargo.toml ($cur_cargo) disagree; fix that first"
appstreamcli vercmp "$cur_meson" "$version" 2>/dev/null | grep -q '<<' \
|| die "$version is not newer than the current $cur_meson"
require_clean_main() {
local branch
branch=$(git symbolic-ref --short -q HEAD || true)
[ "$branch" = main ] || die "not on main (on '${branch:-a detached HEAD}')"
git diff --quiet && git diff --cached --quiet || die "the working tree is dirty"
git fetch --quiet "$REMOTE"
[ "$(git rev-parse HEAD)" = "$(git rev-parse "$REMOTE/main")" ] \
|| die "main is not in sync with $REMOTE/main"
}
SIGNING_KEY=${REGENT_SIGNING_KEY:-$(git config --get user.signingkey || true)}
if [ -z "$SIGNING_KEY" ]; then
for candidate in "$HOME/.ssh/id_ed25519.pub" "$HOME/.ssh/id_rsa.pub"; do
[ -f "$candidate" ] && SIGNING_KEY=$candidate && break
done
fi
[ -n "$SIGNING_KEY" ] || die "no SSH signing key: set REGENT_SIGNING_KEY or user.signingkey"
[ -f "$SIGNING_KEY" ] || die "SSH signing key not found: $SIGNING_KEY"
SIGNER_ID=$(git config --get user.email || true)
[ -n "$SIGNER_ID" ] || die "set user.email; it is the signer identity in allowed_signers"
require_tag_free() {
git rev-parse -q --verify "refs/tags/$tag" >/dev/null && die "tag $tag already exists locally"
git ls-remote --exit-code --tags "$REMOTE" "refs/tags/$tag" >/dev/null 2>&1 \
&& die "tag $tag already exists on $REMOTE"
return 0
}
probe=$(mktemp)
if ! printf 'probe' > "$probe" \
|| ! ssh-keygen -Y sign -f "$SIGNING_KEY" -n regent-probe "$probe" >/dev/null 2>&1; then
resolve_ssh_key() {
local key=${REGENT_SSH_SIGNING_KEY:-} configured
if [ -z "$key" ]; then
configured=$(git config --get user.signingkey || true)
case "$configured" in *.pub) key=$configured ;; esac
fi
if [ -z "$key" ]; then
for candidate in "$HOME/.ssh/id_ed25519.pub" "$HOME/.ssh/id_rsa.pub"; do
[ -f "$candidate" ] && key=$candidate && break
done
fi
printf '%s' "$key"
}
probe_ssh_sign() {
local probe; probe=$(mktemp)
if ! printf 'probe' > "$probe" \
|| ! ssh-keygen -Y sign -f "$1" -n regent-probe "$probe" >/dev/null 2>&1; then
rm -f "$probe" "$probe.sig"
die "cannot sign with $1 — is its private half present (and, on a remote build host, an agent forwarded)?"
fi
rm -f "$probe" "$probe.sig"
die "cannot sign with $SIGNING_KEY — is its private half present, or an agent forwarded (ssh -A)?"
fi
rm -f "$probe" "$probe.sig"
log "version $version (appstream $APPSTREAM, arch $PKGVER, prerelease: $prerelease)"
log "signing as $SIGNER_ID with $SIGNING_KEY"
}
hdr "updating the changelog and the version"
today=$(date +%F)
python3 - "$version" "$today" <<'PY'
resolve_gpg_key() {
local key=${REGENT_GPG_KEY:-}
if [ -z "$key" ]; then
key=$(gpg --batch --list-secret-keys --with-colons 2>/dev/null | awk -F: '/^sec:/ {print $5; exit}')
fi
[ -n "$key" ] || die "no GPG key: set REGENT_GPG_KEY, or import one (gpg --import)"
printf '%s' "$key"
}
gpg_fingerprint() {
gpg --batch --list-keys --with-colons --fingerprint "$1" 2>/dev/null | awk -F: '/^fpr:/ {print $10; exit}'
}
load_release_env() {
[ -f "$DIST/release.env" ] || die "missing $DIST/release.env (run 'prepare' on the build host first)"
r_version=$(env_value version); r_tag=$(env_value tag); r_commit=$(env_value commit)
r_prerelease=$(env_value prerelease); r_pkgver=$(env_value pkgver); r_fingerprint=$(env_value fingerprint)
[ -n "$r_version" ] && [ -n "$r_commit" ] || die "malformed $DIST/release.env"
[ "$r_version" = "$version" ] || die "$DIST/release.env is for $r_version, not $version"
[ "$r_tag" = "$tag" ] || die "$DIST/release.env tag '$r_tag' does not match '$tag'"
}
verify_tarball() {
[ -f "$DIST/regent-$version.tar.xz" ] || die "missing $DIST/regent-$version.tar.xz"
( cd "$DIST" && sha256sum -c "regent-$version.tar.xz.sha256sum" ) >&2
}
pull_dist() {
[ "$pull" = yes ] || die "$DIST/release.env is missing and --no-pull was given"
[ -n "${REGENT_BUILD_HOST:-}" ] || die "$DIST/release.env is missing; set REGENT_BUILD_HOST to pull it, or copy dist/ over"
require_tools ssh tar
local repo=${REGENT_REPO_PATH:-~/src/regent}
log "pulling dist/ from $REGENT_BUILD_HOST:$repo"
mkdir -p "$DIST"
ssh "$REGENT_BUILD_HOST" "cd $repo && tar -C dist -cf - ." | tar -C "$DIST" -xf -
}
# --- stage: prepare (build host) --------------------------------------------
stage_prepare() {
hdr "preflight"
require_tools git meson appstreamcli python3 sha256sum ssh-keygen
require_clean_main
require_tag_free
local cur_meson cur_cargo ssh_key
cur_meson=$(sed -n "s/.*version: '\(.*\)',.*/\1/p" meson.build | head -1)
cur_cargo=$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -1)
[ -n "$cur_meson" ] || die "could not read the version from meson.build"
[ "$cur_meson" = "$cur_cargo" ] \
|| die "meson.build ($cur_meson) and Cargo.toml ($cur_cargo) disagree; fix that first"
appstreamcli vercmp "$cur_meson" "$version" 2>/dev/null | grep -q '<<' \
|| die "$version is not newer than the current $cur_meson"
ssh_key=$(resolve_ssh_key)
[ -n "$ssh_key" ] || die "no SSH signing key: set REGENT_SSH_SIGNING_KEY or user.signingkey"
[ -f "$ssh_key" ] || die "SSH signing key not found: $ssh_key"
probe_ssh_sign "$ssh_key"
log "version $version (appstream $APPSTREAM, arch $PKGVER, prerelease: $prerelease)"
log "commit will be SSH-signed with $ssh_key"
hdr "updating the changelog and the version"
local today; today=$(date +%F)
python3 - "$version" "$today" <<'PY'
import sys
version, today = sys.argv[1], sys.argv[2]
path = "CHANGELOG.md"
@@ -148,114 +221,193 @@ if "## [Unreleased]" not in text:
text = text.replace("## [Unreleased]", f"## [Unreleased]\n\n## [{version}] - {today}", 1)
open(path, "w", encoding="utf-8").write(text)
PY
sed -i "s/^ version: '.*',/ version: '$version',/" meson.build
sed -i "s/^version = \".*\"/version = \"$version\"/" Cargo.toml
cargo update --offline -p regent >/dev/null
python3 build-aux/gen-metainfo-releases.py CHANGELOG.md data/$APP_ID.metainfo.xml.in
sed -i "s/^ version: '.*',/ version: '$version',/" meson.build
sed -i "s/^version = \".*\"/version = \"$version\"/" Cargo.toml
cargo update --offline -p regent >/dev/null
python3 build-aux/gen-metainfo-releases.py CHANGELOG.md data/$APP_ID.metainfo.xml.in
hdr "building and validating"
if [ -d "$BUILD_DIR" ]; then
meson setup --reconfigure "$BUILD_DIR" -Dprofile=default >&2
else
meson setup "$BUILD_DIR" -Dprofile=default >&2
fi
appstreamcli validate --no-net "$BUILD_DIR/data/$APP_ID.metainfo.xml"
desktop-file-validate "$BUILD_DIR/data/$APP_ID.desktop"
glib-compile-schemas --strict --dry-run "$BUILD_DIR/data/"
meson compile -C "$BUILD_DIR" >&2
cargo test --quiet
hdr "committing and tagging"
git add CHANGELOG.md meson.build Cargo.toml Cargo.lock data/$APP_ID.metainfo.xml.in
git -c gpg.format=ssh -c user.signingkey="$SIGNING_KEY" commit -S -m "Release $version"
git -c gpg.format=ssh -c user.signingkey="$SIGNING_KEY" tag -s "$tag" -m "Regent $version"
hdr "building the distribution tarball"
dist_args=()
if [ -n "${REGENT_MESON_DIST_ARGS:-}" ]; then
read -r -a dist_args <<< "$REGENT_MESON_DIST_ARGS"
fi
meson dist -C "$BUILD_DIR" ${dist_args[@]+"${dist_args[@]}"} >&2
tarball="regent-$version.tar.xz"
rm -f "$DIST/$tarball" "$DIST/$tarball.sha256sum" "$DIST/$tarball.sig"
mkdir -p "$DIST"
cp "$BUILD_DIR/meson-dist/$tarball" "$BUILD_DIR/meson-dist/$tarball.sha256sum" "$DIST/"
( cd "$DIST" && sha256sum -c "$tarball.sha256sum" )
sha256=$(cut -d' ' -f1 "$DIST/$tarball.sha256sum")
ssh-keygen -Y sign -f "$SIGNING_KEY" -n file "$DIST/$tarball"
printf '%s %s\n' "$SIGNER_ID" "$(cat "$SIGNING_KEY")" > "$DIST/allowed_signers"
python3 build-aux/gen-metainfo-releases.py --notes "$version" CHANGELOG.md > "$DIST/notes.md"
log "tarball $DIST/$tarball sha256 $sha256"
if [ "$push" = yes ]; then
hdr "pushing"
git push "$REMOTE" main
git push "$REMOTE" "$tag"
if git remote get-url "$NOSTR_REMOTE" >/dev/null 2>&1; then
git push "$NOSTR_REMOTE" main || log "warning: push to $NOSTR_REMOTE main failed (mirror; continuing)"
git push "$NOSTR_REMOTE" "$tag" || log "warning: push to $NOSTR_REMOTE $tag failed (mirror; continuing)"
hdr "building and validating"
if [ -d "$BUILD_DIR" ]; then
meson setup --reconfigure "$BUILD_DIR" -Dprofile=default >&2
else
log "no '$NOSTR_REMOTE' remote; skipping the clone mirror"
meson setup "$BUILD_DIR" -Dprofile=default >&2
fi
appstreamcli validate --no-net "$BUILD_DIR/data/$APP_ID.metainfo.xml"
desktop-file-validate "$BUILD_DIR/data/$APP_ID.desktop"
glib-compile-schemas --strict --dry-run "$BUILD_DIR/data/"
meson compile -C "$BUILD_DIR" >&2
cargo test --quiet
hdr "committing"
git add CHANGELOG.md meson.build Cargo.toml Cargo.lock data/$APP_ID.metainfo.xml.in
git -c gpg.format=ssh -c user.signingkey="$ssh_key" commit -S -m "Release $version"
hdr "building the distribution tarball"
local dist_args=()
if [ -n "${REGENT_MESON_DIST_ARGS:-}" ]; then
read -r -a dist_args <<< "$REGENT_MESON_DIST_ARGS"
fi
meson dist -C "$BUILD_DIR" ${dist_args[@]+"${dist_args[@]}"} >&2
local tarball="regent-$version.tar.xz"
mkdir -p "$DIST"
rm -f "$DIST/$tarball" "$DIST/$tarball.sha256sum"
cp "$BUILD_DIR/meson-dist/$tarball" "$BUILD_DIR/meson-dist/$tarball.sha256sum" "$DIST/"
( cd "$DIST" && sha256sum -c "$tarball.sha256sum" ) >&2
python3 build-aux/gen-metainfo-releases.py --notes "$version" CHANGELOG.md > "$DIST/notes.md"
hdr "recording the handoff"
cat > "$DIST/release.env" <<EOF
version=$version
tag=$tag
prerelease=$prerelease
appstream=$APPSTREAM
pkgver=$PKGVER
commit=$(git rev-parse HEAD)
EOF
log "tarball $DIST/$tarball (sha256 $(cut -d' ' -f1 "$DIST/$tarball.sha256sum"))"
log "prepared $version at commit $(git rev-parse --short HEAD)"
if [ "$push" = yes ]; then
hdr "pushing main"
git push "$REMOTE" main
if git remote get-url "$NOSTR_REMOTE" >/dev/null 2>&1; then
git push "$NOSTR_REMOTE" main || warn "push to $NOSTR_REMOTE main failed (mirror; continuing)"
fi
fi
hdr "next"
log "next, on the machine with the GPG key:"
log " REGENT_BUILD_HOST=<this-host> build-aux/release.sh sign $version"
}
# --- stage: sign (laptop, GPG) ----------------------------------------------
stage_sign() {
hdr "preflight"
require_tools git gpg sha256sum sed
[ -f "$DIST/release.env" ] || pull_dist
load_release_env
verify_tarball
require_clean_main
[ "$(git rev-parse HEAD)" = "$r_commit" ] \
|| die "HEAD ($(git rev-parse --short HEAD)) is not the prepared commit (${r_commit:0:8}); pull main first"
require_tag_free
local gpg_key fpr
gpg_key=$(resolve_gpg_key)
fpr=$(gpg_fingerprint "$gpg_key")
[ -n "$fpr" ] || die "could not read the fingerprint of GPG key $gpg_key"
log "signing with GPG key $gpg_key ($fpr)"
hdr "signing the tarball"
rm -f "$DIST/regent-$version.tar.xz.asc" "$DIST/regent-signing-key.asc"
gpg --batch --yes --armor --detach-sign --local-user "$gpg_key" "$DIST/regent-$version.tar.xz"
gpg --batch --yes --armor --export "$gpg_key" > "$DIST/regent-signing-key.asc"
gpg --batch --verify "$DIST/regent-$version.tar.xz.asc" "$DIST/regent-$version.tar.xz" >&2
# Record the fingerprint for `publish`, which fills the AUR validpgpkeys.
sed -i '/^fingerprint=/d' "$DIST/release.env"
printf 'fingerprint=%s\n' "$fpr" >> "$DIST/release.env"
hdr "tagging"
git -c gpg.format=openpgp -c user.signingkey="$gpg_key" tag -s "$tag" -m "Regent $version"
git tag -v "$tag" >&2 || die "could not verify the tag just created"
if [ "$push" = yes ]; then
hdr "pushing the tag"
git push "$REMOTE" "$tag"
if git remote get-url "$NOSTR_REMOTE" >/dev/null 2>&1; then
git push "$NOSTR_REMOTE" "$tag" || warn "push to $NOSTR_REMOTE $tag failed (mirror; continuing)"
fi
fi
hdr "next"
log "run: build-aux/release.sh publish $version"
}
# --- stage: publish (laptop) -------------------------------------------------
stage_publish() {
hdr "preflight"
require_tools git gt makepkg sed
[ "$nostr" = no ] || require_tools ngit
load_release_env
verify_tarball
[ -f "$DIST/regent-$version.tar.xz.asc" ] || die "missing $DIST/regent-$version.tar.xz.asc (run 'sign' first)"
[ -n "$r_fingerprint" ] || die "$DIST/release.env has no fingerprint (run 'sign' first)"
require_clean_main
[ "$(git rev-parse HEAD)" = "$r_commit" ] || die "HEAD is not the released commit; check out main and pull"
git rev-parse -q --verify "refs/tags/$tag" >/dev/null || die "tag $tag is missing (run 'sign' first)"
if [ "$push" = no ] && [ "$draft" = no ]; then
warn "publishing without --draft while pushing nothing; the post-release commit will stay local"
fi
fi
if [ "$release" = yes ]; then
hdr "creating the Gitea release"
args=(release create "$tag" --verify-tag
"$DIST/$tarball"
"$DIST/$tarball.sha256sum"
"$DIST/$tarball.sig"
"$DIST/allowed_signers"
local args=(release create "$tag" --verify-tag
"$DIST/regent-$version.tar.xz"
"$DIST/regent-$version.tar.xz.sha256sum"
"$DIST/regent-$version.tar.xz.asc"
"$DIST/regent-signing-key.asc"
build-aux/aur/regent/PKGBUILD
-F "$DIST/notes.md")
[ "$prerelease" = yes ] && args+=(--prerelease)
[ "$draft" = yes ] && args+=(--draft)
gt "${args[@]}"
fi
tmp=
if [ "$aur" = yes ]; then
hdr "updating the AUR"
tmp=$(mktemp -d)
trap 'rm -rf "$tmp"' EXIT
sed -i -e "s/^pkgver=.*/pkgver=$PKGVER/" \
-e "s/^_tag=.*/_tag=$version/" \
-e "s/^sha256sums=.*/sha256sums=('$sha256')/" \
build-aux/aur/regent/PKGBUILD
for pkg in regent regent-git; do
url=$AUR_REGENT; [ "$pkg" = regent-git ] && url=$AUR_GIT
git clone --quiet "$url" "$tmp/$pkg"
install -m644 "build-aux/aur/$pkg/PKGBUILD" "$tmp/$pkg/PKGBUILD"
( cd "$tmp/$pkg"
makepkg --printsrcinfo > .SRCINFO
if git diff --quiet && git diff --cached --quiet; then
log "$pkg: no change"
else
git add PKGBUILD .SRCINFO
git commit -q -m "Update to $version"
git push --quiet origin master
log "$pkg: pushed $version"
fi )
done
fi
if [ "$nostr" = yes ]; then
hdr "publishing the Nostr release"
channel=main; [ "$prerelease" = yes ] && channel=beta
ngit release publish "$version" --tag "$tag" --channel "$channel"
fi
if [ "$aur" = yes ]; then
hdr "post-release"
git add build-aux/aur/regent/PKGBUILD
if ! git diff --cached --quiet; then
git -c gpg.format=ssh -c user.signingkey="$SIGNING_KEY" \
commit -S -m "Post-release: point the AUR recipe at $version"
[ "$push" = yes ] && git push "$REMOTE" main
if [ "$aur" = yes ]; then
hdr "updating the AUR"
local sha
sha=$(cut -d' ' -f1 "$DIST/regent-$version.tar.xz.sha256sum")
sed -i -e "s/^pkgver=.*/pkgver=$PKGVER/" \
-e "s/^_tag=.*/_tag=$version/" \
-e "s/^_fingerprint=.*/_fingerprint=$r_fingerprint/" \
-e "s/^sha256sums=.*/sha256sums=('$sha' 'SKIP')/" \
build-aux/aur/regent/PKGBUILD
AUR_TMP=$(mktemp -d)
trap '[ -n "${AUR_TMP:-}" ] && rm -rf "$AUR_TMP"' EXIT
local pkg url
for pkg in regent regent-git; do
url=$AUR_REGENT; [ "$pkg" = regent-git ] && url=$AUR_GIT
git clone --quiet "$url" "$AUR_TMP/$pkg"
install -m644 "build-aux/aur/$pkg/PKGBUILD" "$AUR_TMP/$pkg/PKGBUILD"
( cd "$AUR_TMP/$pkg"
makepkg --printsrcinfo > .SRCINFO
if git diff --quiet && git diff --cached --quiet; then
log "$pkg: no change"
else
git add PKGBUILD .SRCINFO
git commit -q -m "Update to $version"
git push --quiet origin master
log "$pkg: pushed $version"
fi )
done
rm -rf "$AUR_TMP"; AUR_TMP=
fi
fi
hdr "done"
log "released $version (tag $tag)"
[ "$release" = yes ] && log "release: https://gitea.kosmos.org/raucao/regent/releases/tag/$tag" || true
exit 0
if [ "$nostr" = yes ]; then
hdr "publishing the Nostr release"
local channel=main; [ "$prerelease" = yes ] && channel=beta
ngit release publish "$version" --tag "$tag" --channel "$channel"
fi
if [ "$aur" = yes ]; then
hdr "post-release"
git add build-aux/aur/regent/PKGBUILD
if ! git diff --cached --quiet; then
git commit -m "Post-release: point the AUR recipe at $version"
[ "$push" = yes ] && git push "$REMOTE" main
fi
fi
hdr "done"
log "released $version (tag $tag)"
[ "$push" = yes ] && log "release: https://gitea.kosmos.org/raucao/regent/releases/tag/$tag"
return 0
}
case "$stage" in
prepare) stage_prepare ;;
sign) stage_sign ;;
publish) stage_publish ;;
esac
+68 -56
View File
@@ -1,42 +1,70 @@
# Releasing
How to cut a Regent release: build, sign, tag, and publish it to Gitea, the AUR
and Nostr.
How to cut a Regent release: build it on the build host, sign it on the machine
that holds the GPG key, then publish it to Gitea, the AUR and Nostr.
> Scope: maintainers cutting a release. For local setup, building, running and
> testing, see [Development](development.md).
Releases are cut from `main` with one script:
## Who signs what, and where
The two keys live on different machines, so a release is three stages:
| Stage | Machine | Signs with |
| --- | --- | --- |
| `prepare` | build host | **SSH** — the release commit |
| `sign` | laptop | **GPG** — the tag and the tarball |
| `publish` | laptop | — |
The GPG key never touches the build host. The release **commit** is SSH-signed
(not GPG); the **tag** and the detached tarball signature are GPG.
## Cutting a release
On the build host:
```sh
build-aux/release.sh 1.0.0-beta.1
build-aux/release.sh prepare 1.0.0-beta.1
```
It bumps the version, builds and signs the distribution tarball, tags it, and
publishes it. The run is linear and stops at the first failure.
## Signing
Signing is **SSH-only** (git's `gpg.format=ssh`) — no GPG:
- the annotated git tag is signed (`git tag -s`),
- a detached signature over the tarball is made with `ssh-keygen -Y sign`, and a
matching `allowed_signers` file is attached to the release.
That lets the key stay on your laptop: forward your agent and run the script on
the build host, where the compile happens.
On the machine with the GPG key:
```sh
ssh -A user@build-host
build-aux/release.sh sign 1.0.0-beta.1
build-aux/release.sh publish 1.0.0-beta.1
```
The key comes from `REGENT_SIGNING_KEY`, else `git config user.signingkey`, else
`~/.ssh/id_ed25519.pub`. The script proves it can sign before it writes
anything, so a missing key or agent fails up front.
`sign` pulls `dist/` from the build host over SSH when it is not there yet, so set
`REGENT_BUILD_HOST` there. Each stage is linear and stops at the first failure.
The commit is signed too, which is why the commit and its tag are cut *before*
`meson dist`: the tarball is built from that commit, and re-signing the commit
afterwards would change its hash and break the release's provenance.
## `prepare` (build host)
Checks that you are on a clean `main` in sync with `origin`, that the tag is
free, and that the version is newer than the current one; then it bumps the
version in `meson.build`/`Cargo.toml`/`Cargo.lock`, closes the `[Unreleased]`
changelog section, regenerates the metainfo, validates, builds and tests, and
commits the result **SSH-signed** (the key comes from `REGENT_SSH_SIGNING_KEY`,
else `git config user.signingkey`, else `~/.ssh/id_ed25519.pub`). It then runs
`meson dist` and leaves the tarball, the checksum, the release notes and a
`release.env` handoff in `dist/`, and pushes `main`.
## `sign` (laptop)
Verifies the tarball against `release.env` and `sha256sum`, then:
- `gpg --armor --detach-sign` → `dist/regent-<version>.tar.xz.asc`,
- exports the public key → `dist/regent-signing-key.asc`,
- `git tag -s` (GPG) and pushes the tag.
The key comes from `REGENT_GPG_KEY`, else the first secret key in the keyring.
## `publish` (laptop)
Creates the Gitea release (the tarball, its `.sha256sum`, its `.asc`, the public
key, the `PKGBUILD` and the notes; pre-releases are marked as such), updates the
AUR recipes — `regent` gains the real sha256, the `.asc` in `source` and the
fingerprint in `validpgpkeys` — publishes the Nostr release, and commits the
in-repo AUR recipe snapshot.
## One version, three dialects
@@ -53,43 +81,27 @@ final release:
## Release notes
Release notes live in `CHANGELOG.md` and nowhere else. Write the new section
under `## [Unreleased]` before releasing; the script renames that heading to the
version and date. The AppStream release entries in the metainfo are generated
from the same file by `build-aux/gen-metainfo-releases.py` — do not edit the
under `## [Unreleased]` before releasing; `prepare` renames that heading to the
version and date. The AppStream release entries are generated from the same file
by `build-aux/gen-metainfo-releases.py` — do not edit the
`releases:begin`/`releases:end` block by hand.
## What a release publishes
## Skipping steps
- **Gitea** (canonical): a release for the tag, carrying the source tarball, its
`.sha256sum`, its `.sig`, `allowed_signers`, and the AUR `PKGBUILD`; the notes
come from `CHANGELOG.md`. Pre-releases are marked as such.
- **AUR**: `regent` (the released tarball) and `regent-git` (tracks `main`).
- **Nostr** (mirror): `.ngit/release.yaml` publishes the same files to Blossom
under NIP-82, signed by the fixed release identity.
## Previewing without publishing
Every outward-facing step can be turned off, so a build can be prepared and
reviewed before it goes anywhere:
```sh
build-aux/release.sh 1.0.0-beta.1 \
--no-push --no-release --no-aur --no-nostr # build, commit, tag and sign only
```
- `--draft` — open the Gitea release as a draft instead of publishing it.
- `--no-push`, `--no-release`, `--no-aur`, `--no-nostr` — skip that step.
- `REGENT_MESON_DIST_ARGS=--no-tests` — skip `meson dist`'s build-and-test of the
tarball (it doubles the build time; the pre-flight build already ran).
Undo a preview run with `git reset --soft HEAD~1 && git tag -d vX.Y.Z`.
- `--draft` (`publish`) — open the Gitea release as a draft.
- `--no-push` (`prepare`, `sign`, `publish`) — do not push.
- `--no-aur`, `--no-nostr` (`publish`) — skip that destination.
- `--no-pull` (`sign`) — fail instead of pulling `dist/` from the build host.
- `REGENT_MESON_DIST_ARGS=--no-tests` (`prepare`) — skip `meson dist`'s
build-and-test of the tarball.
## One-time setup
- An SSH signing key (`git config user.signingkey`), available to the agent.
- Gitea: protect `v*` tags so only maintainers can cut release tags, and run
`gt auth login` where the script runs.
- AUR: the `regent` and `regent-git` packages created, with the AUR SSH key where
the script runs.
- A **GPG** key for signing tags and tarballs, on the laptop; publish its
fingerprint.
- An **SSH** key for signing the release commit, on the build host.
- Gitea: protect `v*` tags; `gt auth login` where `publish` runs.
- AUR: the `regent` and `regent-git` packages, with the AUR SSH key where
`publish` runs.
- Nostr: the ngit signer for the repository's npub, which must stay the same for
every release.