Files
th-hotel-simple/scripts/package-server-with-build-info.sh
2026-07-21 14:21:09 +07:00

31 lines
1.0 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "$repo_root"
git update-index -q --refresh
if [[ -n "$(git status --porcelain)" ]]; then
echo "ERROR: Git worktree is not clean. Commit or stash changes before packaging a deployment-proof Jar." >&2
git status --short >&2
exit 1
fi
build_commit="$(git rev-parse --short HEAD 2>/dev/null || true)"
if [[ -z "$build_commit" || "$build_commit" == "UNKNOWN" ]]; then
echo "ERROR: Cannot resolve current Git commit for TH_HOTEL_BUILD_COMMIT." >&2
exit 1
fi
echo "Packaging TH Hotel backend with TH_HOTEL_BUILD_COMMIT=$build_commit"
cd "$repo_root/server"
TH_HOTEL_BUILD_COMMIT="$build_commit" ./mvnw clean package "$@"
build_info_file="$repo_root/server/target/classes/META-INF/build-info.properties"
if ! grep -q "^build.commit=$build_commit$" "$build_info_file"; then
echo "ERROR: build-info verification failed. Expected build.commit=$build_commit in $build_info_file." >&2
exit 1
fi
echo "Build proof OK: build.commit=$build_commit"