strawberry/scripts/release.sh
trvon 43efeac44c
Some checks failed
release / draft (push) Has been skipped
release / build (debian:trixie, trixie) (push) Has been cancelled
release / build (ubuntu:24.04, noble) (push) Has been cancelled
release / publish (push) Has been skipped
Release: one version source, CI version contract, scripts/release.sh
The version lived in three hard-coded copies (CLI `version`, daemon status,
banner); v0.2.0 shipped with the CLI still saying 0.1.0. meson.build is now
the only source: it passes STRAWBERRY_VERSION to every target, and the CLI
test requires the exact version.

packaging/ci/build-release.sh refuses to publish a tag build unless
meson.build, the tag and the built binary's `strawberry version` agree; CI
never rewrites the version.

scripts/release.sh X.Y.Z is the one manual release step: on a clean main
equal to forgejo/main it bumps meson.build, makes a signed commit and a
signed tag, and pushes both (--dry-run shows the plan). The Security Hub
release channel deploys signed tags only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 08:55:05 -07:00

41 lines
2.5 KiB
Bash
Executable file

#!/usr/bin/env bash
# Cut a strawberry release: bump meson.build, commit, signed tag, push. The only manual release step.
#
# scripts/release.sh 0.2.1 # remote: forgejo
# scripts/release.sh 0.2.1 --dry-run # checks and the planned commands, changes nothing
#
# The Forgejo release lane (.forgejo/workflows/release.yml) builds the tag and publishes only when meson.build, the tag
# and the built binary agree (packaging/ci/build-release.sh). The Security Hub release channel deploys signed tags only.
set -euo pipefail
version=${1:?usage: scripts/release.sh X.Y.Z[-pre] [--dry-run]}
dry=${2:-}
remote=${STRAWBERRY_RELEASE_REMOTE:-forgejo}
tag="v$version"
die() { echo "release: $*" >&2; exit 1; }
[[ "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.]+)?$ ]] || die "version must look like 1.2.3 or 1.2.3-rc.1"
cd "$(git rev-parse --show-toplevel)"
[ "$(git rev-parse --abbrev-ref HEAD)" = "main" ] || die "run from main"
[ -z "$(git status --porcelain --untracked-files=no)" ] || die "tracked changes present; commit or stash first"
git fetch -q "$remote" main --tags
[ "$(git rev-parse HEAD)" = "$(git rev-parse "$remote/main")" ] || die "main is not equal to $remote/main; pull or push first"
git rev-parse -q --verify "refs/tags/$tag" >/dev/null && die "tag $tag already exists"
current=$(sed -n "s/^ version: '\(.*\)',$/\1/p" meson.build | head -1)
[ -n "$current" ] || die "cannot read the version from meson.build"
[ "$current" != "$version" ] || die "meson.build is already $version"
[ "$(git config --get tag.gpgSign || true)" = "true" ] || [ -n "$(git config --get user.signingkey || true)" ] || die "no signing key configured (tag must be signed)"
echo "release $current -> $version on $remote (HEAD $(git rev-parse --short HEAD))"
if [ "$dry" = "--dry-run" ]; then
echo "would: bump meson.build, commit 'Release $tag' (signed), tag -s $tag, push $remote main $tag"
exit 0
fi
sed -i.bak "s/^ version: '$current',$/ version: '$version',/" meson.build && rm -f meson.build.bak
[ "$(sed -n "s/^ version: '\(.*\)',$/\1/p" meson.build | head -1)" = "$version" ] || die "meson.build bump failed"
git add meson.build
git commit -q -S -m "Release $tag"
git tag -s "$tag" -m "strawberry $tag"
git verify-tag "$tag" >/dev/null 2>&1 || echo "release: note: local gpg cannot verify $tag (public key not imported here)" >&2
git push -q "$remote" main "$tag"
echo "pushed $tag; the release lane builds it: $(git remote get-url "$remote" | sed 's#ssh://git@\([^:/]*\).*/\([^/]*\)/\([^/.]*\).*#https://\1/\2/\3#')/actions"