build(scripts): embed version info in macOS build script

Use git describe/rev-parse for version/commit and pass via ldflags.
This commit is contained in:
Finessse
2026-01-11 08:43:00 +07:00
parent 46ad228707
commit 0420fd0046
+13 -4
View File
@@ -8,11 +8,20 @@ compat_path="$out_dir/cliproxyapi-latest"
mkdir -p "$out_dir"
echo "Building ProxyPilot Engine..."
echo " out: $out_path"
echo " compat: $compat_path"
# Version info from git
VERSION="${VERSION:-$(git -C "$repo_root" describe --tags --always 2>/dev/null || echo "dev")}"
COMMIT="${COMMIT:-$(git -C "$repo_root" rev-parse --short HEAD 2>/dev/null || echo "none")}"
BUILD_DATE="${BUILD_DATE:-$(date -u +"%Y-%m-%dT%H:%M:%SZ")}"
(cd "$repo_root" && go build -o "$out_path" ./cmd/server)
LDFLAGS="-X main.Version=$VERSION -X main.Commit=$COMMIT -X main.BuildDate=$BUILD_DATE"
echo "Building ProxyPilot Engine..."
echo " version: $VERSION"
echo " commit: $COMMIT"
echo " built: $BUILD_DATE"
echo " out: $out_path"
(cd "$repo_root" && go build -ldflags "$LDFLAGS" -o "$out_path" ./cmd/server)
cp -f "$out_path" "$compat_path" 2>/dev/null || true
echo "Done."