From 0420fd0046cfd13ea15e25872ea51560529326ce Mon Sep 17 00:00:00 2001 From: Finessse Date: Sun, 11 Jan 2026 08:43:00 +0700 Subject: [PATCH] build(scripts): embed version info in macOS build script Use git describe/rev-parse for version/commit and pass via ldflags. --- scripts/macos/build-cliproxyapi.sh | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/scripts/macos/build-cliproxyapi.sh b/scripts/macos/build-cliproxyapi.sh index 817bcdbc..da155fd3 100644 --- a/scripts/macos/build-cliproxyapi.sh +++ b/scripts/macos/build-cliproxyapi.sh @@ -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."