Files
RustBox/scripts/build-release.sh
T
2026-10-31 14:36:07 +01:00

51 lines
1.3 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "$ROOT"
# Cargo.lock is generated only for the locked build/test phase. Keep source releases
# and the working tree clean so the offline/static gate is repeatable.
cleanup_lockfile() {
rm -f "$ROOT/Cargo.lock"
}
trap cleanup_lockfile EXIT
rm -f "$ROOT/Cargo.lock"
if ! command -v cargo >/dev/null 2>&1; then
echo "error: Rust/Cargo is required" >&2
exit 1
fi
if find "$ROOT" -type f \( -name '*.ts' -o -name '*.tsx' \) -print -quit | grep -q .; then
echo "error: TypeScript source found in RustBox" >&2
exit 1
fi
if [[ -e "$ROOT/src/web/app.js" || ! -f "$ROOT/src/web/js/manifest.txt" ]]; then
echo "error: browser JavaScript must be modularized under src/web/js/" >&2
exit 1
fi
if command -v python3 >/dev/null 2>&1; then
python3 scripts/validate-release-static.py
else
echo "error: python3 is required for static release validation" >&2
exit 1
fi
if [[ ! -f Cargo.lock ]]; then
cargo generate-lockfile
fi
cargo fmt --all
cargo fmt --all -- --check
cargo test --locked
cargo clippy --locked --all-targets -- -D warnings
cargo build --release --locked
BIN="$ROOT/target/release/rustbox"
test -x "$BIN"
"$BIN" --version
printf 'Built RustBox: %s\n' "$BIN"