Files
raucao 07a7976711 Add the release tooling (Gitea + AUR + Nostr)
build-aux/release.sh cuts a release from main: it bumps the version in
meson.build/Cargo.toml/Cargo.lock, generates the AppStream release entry from
CHANGELOG.md, builds and signs the distribution 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's gpg.format=ssh): an annotated tag plus an
ssh-keygen -Y sign detached signature over the tarball. That lets the key stay
on a laptop — run the script under ssh -A and the forwarded agent signs, so the
key material never lands on the build host.

Also:
- CHANGELOG.md: the single source of release notes (Keep a Changelog).
- build-aux/gen-metainfo-releases.py: generates the metainfo <releases> block
  from it, translating the version dialect (1.0.0-beta.1 -> 1.0.0~beta.1, with
  type=development) and exposing --notes for the release notes text.
- build-aux/aur/{regent,regent-git}: the AUR recipes (release tarball and VCS).
- build-aux/regent-dev: the working-tree package, renamed from regent-git to
  make room for the AUR regent-git; deploy-dev.sh --pkg builds this one.
- .ngit/release.yaml: the NIP-82 release manifest (Blossom mirror at
  blossom.kosmos.org), replacing the hand-rolled NIP-94/30063/32267 plan.
- Docs: README (install + verify), doc/dev/development.md (Releasing),
  AGENTS.md (Releases).

This adds tooling only: it cuts no tag and publishes nothing.
2026-11-29 23:57:07 +04:00

111 lines
4.0 KiB
Bash
Executable File

#!/usr/bin/env bash
# Build Regent and produce something installable elsewhere.
#
# Runs on the build host. Modes:
# --emit stream a tar.zst of the install tree on stdout (logs go to
# stderr) so the other machine can pipe it straight into tar:
# ssh HOST '<repo>/build-aux/deploy-dev.sh --emit' \
# | tar -x --zstd -C ~/.local
# (default) write that same tarball to a file and print its path
# --pkg build the `regent-dev` pacman package and print its path
# --versions print the GTK/libadwaita versions this host builds against
#
# REGENT_PROFILE=development builds the nightly `.Devel` identity (its own app id,
# icon, desktop file, D-Bus name and data directories, and a `regent-devel`
# binary) instead of the stable one; see meson.options. The release `--pkg` build
# is always stable.
#
# The install tree is rooted at /usr, so extracting it into $HOME/.local yields
# the XDG layout: ~/.local/bin/regent, ~/.local/share/<app-id>/, ...
set -euo pipefail
log() { printf 'deploy: %s\n' "$*" >&2; }
die() { printf 'deploy: %s\n' "$*" >&2; exit 1; }
ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)
cd "$ROOT"
MODE=stage
case "${1:-}" in
--emit) MODE=emit ;;
--pkg) MODE=pkg ;;
--versions) MODE=versions ;;
''|--stage) ;;
-h|--help) sed -n '2,20p' "${BASH_SOURCE[0]}" | sed 's/^# \{0,1\}//'; exit 0 ;;
*) die "unknown option: $1 (try --help)" ;;
esac
if [ "$MODE" = versions ]; then
printf 'gtk4=%s libadwaita=%s\n' \
"$(pkg-config --modversion gtk4)" "$(pkg-config --modversion libadwaita-1)"
exit 0
fi
# Which application identity to build. `development` is the `.Devel` nightly,
# which gets its own app id, icon, desktop file, D-Bus name and data directories
# so it can be installed beside the stable one. The release `--pkg` build is
# always stable, whatever the caller asked for.
PROFILE=${REGENT_PROFILE:-default}
case "$PROFILE" in
default|development) ;;
*) die "unknown profile: $PROFILE (default or development)" ;;
esac
if [ "$MODE" = pkg ]; then
PROFILE=default
fi
for tool in cargo meson pkg-config tar zstd; do
command -v "$tool" >/dev/null || die "$tool not found"
done
# Version stamp: crate version plus commit count and short SHA, so each build
# from a new commit sorts higher than the previous one.
CARGO_VER=$(sed -n 's/^version *= *"\(.*\)"/\1/p' Cargo.toml | head -1)
SHA=$(git rev-parse --short HEAD 2>/dev/null || echo unknown)
COUNT=$(git rev-list --count HEAD 2>/dev/null || echo 0)
DIRTY=""
git diff --quiet --ignore-submodules HEAD 2>/dev/null || DIRTY=".dirty"
PKGVER="${CARGO_VER:-0.0.0}.r${COUNT}.g${SHA}${DIRTY}"
log "version ${PKGVER}"
OUT_DIR=${REGENT_OUT_DIR:-/tmp/regent-dev}
mkdir -p "$OUT_DIR"
if [ "$MODE" = pkg ]; then
command -v makepkg >/dev/null || die "makepkg not found"
log "building regent-dev with makepkg"
( cd build-aux/regent-dev \
&& REGENT_DEV_PKGVER="$PKGVER" REGENT_REPO="$ROOT" makepkg -f --noconfirm ) >&2
PKG=$(ls -t build-aux/regent-dev/regent-dev-*.pkg.tar.* | head -1)
install -m644 "$PKG" "$OUT_DIR/"
printf '%s\n' "$OUT_DIR/$(basename "$PKG")"
exit 0
fi
BUILD_DIR=${REGENT_BUILD_DIR:-_build}
# `meson install` cannot change the prefix, so the build directory is always
# configured with /usr — the staged tree is then $STAGE/usr, which unpacks into
# $HOME/.local as the standard XDG layout.
if [ -d "$BUILD_DIR" ]; then
meson setup --reconfigure --prefix=/usr -Dprofile="$PROFILE" "$BUILD_DIR" >&2
else
log "configuring $BUILD_DIR (profile: $PROFILE)"
meson setup --prefix=/usr -Dprofile="$PROFILE" "$BUILD_DIR" >&2
fi
log "compiling"
meson compile -C "$BUILD_DIR" >&2
STAGE=$(mktemp -d "${TMPDIR:-/tmp}/regent-stage.XXXXXX")
trap 'rm -rf "$STAGE"' EXIT
log "staging the install tree"
meson install -C "$BUILD_DIR" --destdir "$STAGE" --quiet >&2
if [ "$MODE" = emit ]; then
log "streaming the install tree to stdout"
tar -C "$STAGE/usr" -cf - . | zstd -q -c
else
OUT="$OUT_DIR/regent-$PKGVER.tar.zst"
tar -C "$STAGE/usr" -cf - . | zstd -q -c > "$OUT"
printf '%s\n' "$OUT"
fi