Files
ActivePush/build-release.sh
T
2026-11-05 12:52:32 +01:00

50 lines
1.9 KiB
Bash
Executable File

#!/usr/bin/env bash
# Full release pipeline: lint, tests, optimised binary, Debian package, source archive, checksums.
set -euo pipefail
ROOT="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
cd "$ROOT"
fail() { printf 'error: %s\n' "$*" >&2; exit 1; }
need() { command -v "$1" >/dev/null 2>&1 || fail "$1 is required"; }
need cargo; need rustc; need python3; need sha256sum; need tar
VERSION="$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -1)"
HOST="$(rustc -vV | sed -n 's/^host: //p')"
[[ -f Cargo.lock ]] || fail "Cargo.lock is required for a reproducible release"
printf 'ActivePush %s release build for %s\n' "$VERSION" "$HOST"
cargo fmt --all -- --check
cargo clippy --locked --all-targets -- -D warnings
python3 scripts/check-wbxml-names.py
if command -v node >/dev/null; then node --check web/app.js; fi
cargo test --locked --lib --bins
if command -v cargo-zigbuild >/dev/null 2>&1 && [[ "${GLIBC_TARGET:-2.31}" != "0" ]]; then
# portable binary (old glibc baseline)
cargo zigbuild --locked --release --target "$(uname -m)-unknown-linux-gnu.${GLIBC_TARGET:-2.31}"
BIN="target/$(uname -m)-unknown-linux-gnu/release/active-push"
else
cargo build --locked --release
BIN="target/release/active-push"
fi
[[ -x "$BIN" ]] || fail "release binary missing"
"$BIN" --version
rm -rf dist && mkdir -p dist
ART="active-push-${VERSION}-${HOST}"
cp "$BIN" "dist/$ART"
chmod 0755 "dist/$ART"
(cd dist && sha256sum "$ART" > "$ART.sha256")
if command -v dpkg-deb >/dev/null; then
BIN="$BIN" scripts/build-deb.sh --no-build
else
printf 'dpkg-deb not found: skipping .deb\n'
fi
SRC="dist/active-push-${VERSION}-source.tar.gz"
tar --exclude=./target --exclude=./data --exclude=./dist --exclude=./.git --exclude=./.env \
-czf "$SRC" --transform "s,^\.,active-push-${VERSION}," .
(cd dist && sha256sum "$(basename "$SRC")" > "$(basename "$SRC").sha256")
printf '\nRelease artifacts:\n'
ls -1 dist