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>
82 lines
3.2 KiB
Bash
Executable file
82 lines
3.2 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
# Build, test and pack a Linux install tree for one distro. CI containers only:
|
|
# it installs build packages with apt.
|
|
#
|
|
# packaging/ci/build-release.sh <trixie|noble> [outdir]
|
|
#
|
|
# Output: <outdir>/strawberry-<version>-<os>-<arch>.tgz and a .sha256 next to it.
|
|
# The tarball holds what scripts/install.sh reads from a source tree:
|
|
# builddir/src/strawberry, builddir/src/process_monitor.bpf.o, scripts/, config/, packaging/.
|
|
set -euo pipefail
|
|
|
|
os=${1:?usage: build-release.sh <trixie|noble> [outdir]}
|
|
out=${2:-dist}
|
|
jobs=${JOBS:-2}
|
|
|
|
case "$os" in
|
|
trixie) want_id=debian want_codename=trixie ;;
|
|
noble) want_id=ubuntu want_codename=noble ;;
|
|
*) echo "unsupported os: $os" >&2; exit 2 ;;
|
|
esac
|
|
|
|
if [ "${CI:-}" != "true" ]; then
|
|
echo "refusing to run outside CI (it installs packages); set CI=true in a throwaway container" >&2
|
|
exit 2
|
|
fi
|
|
. /etc/os-release
|
|
if [ "$ID" != "$want_id" ] || [ "${VERSION_CODENAME:-}" != "$want_codename" ]; then
|
|
echo "container is $ID ${VERSION_CODENAME:-?}, expected $want_id $want_codename" >&2
|
|
exit 2
|
|
fi
|
|
|
|
export DEBIAN_FRONTEND=noninteractive
|
|
apt-get update -q
|
|
# Same set as the Dockerfile base stage, minus Qt (the tray app is not shipped to servers).
|
|
apt-get install -y -q --no-install-recommends \
|
|
bash ca-certificates ccache clang cmake curl g++ git llvm make meson ninja-build pkg-config python3 \
|
|
libbpf-dev libssl-dev libyara-dev nlohmann-json3-dev libcurl4-openssl-dev libarchive-dev libzstd-dev \
|
|
procps util-linux iproute2
|
|
|
|
# Version contract: a tag build publishes only when meson.build, the tag and the built binary agree.
|
|
# scripts/release.sh bumps meson.build in the release commit; CI never rewrites the version.
|
|
src_version=$(sed -n "s/^ version: '\(.*\)',$/\1/p" meson.build | head -1)
|
|
if [ "${GITHUB_REF_TYPE:-}" = "tag" ]; then
|
|
tag_version=${GITHUB_REF_NAME#v}
|
|
if [ "$src_version" != "$tag_version" ]; then
|
|
echo "meson.build version $src_version does not match tag $GITHUB_REF_NAME; cut releases with scripts/release.sh" >&2
|
|
exit 1
|
|
fi
|
|
fi
|
|
|
|
export CC=gcc CXX=g++
|
|
rm -rf builddir
|
|
meson setup builddir -Denable_app=disabled -Denable_tests=true
|
|
nice -n 19 ninja -C builddir -j"$jobs"
|
|
nice -n 19 meson test -C builddir --print-errorlogs --num-processes "$jobs"
|
|
|
|
for f in builddir/src/strawberry builddir/src/process_monitor.bpf.o; do
|
|
test -s "$f" || { echo "missing build output: $f" >&2; exit 1; }
|
|
done
|
|
|
|
built_version=$(builddir/src/strawberry version | awk '{print $2}')
|
|
if [ "$built_version" != "$src_version" ]; then
|
|
echo "built binary reports $built_version, meson.build says $src_version" >&2
|
|
exit 1
|
|
fi
|
|
if [ "${GITHUB_REF_TYPE:-}" = "tag" ]; then
|
|
version=$tag_version
|
|
else
|
|
version="${src_version}+g$(git rev-parse --short=12 HEAD)"
|
|
fi
|
|
arch=$(dpkg --print-architecture)
|
|
name="strawberry-${version}-${os}-${arch}.tgz"
|
|
|
|
mkdir -p "$out"
|
|
epoch=$(git log -1 --format=%ct)
|
|
# Reproducible-ish archive: fixed order, owner and mtime; gzip without a timestamp.
|
|
tar --sort=name --owner=0 --group=0 --numeric-owner --mtime="@${epoch}" -cf - \
|
|
scripts config packaging builddir/src/strawberry builddir/src/process_monitor.bpf.o \
|
|
| gzip -n -9 > "$out/$name"
|
|
(cd "$out" && sha256sum "$name" > "$name.sha256")
|
|
echo "built $out/$name"
|
|
cat "$out/$name.sha256"
|