build: 注入 patched CPA 版本信息

This commit is contained in:
chuan
2026-08-16 23:53:41 +08:00
parent a2d48de419
commit 2b53af06c5
2 changed files with 10 additions and 1 deletions
+9 -1
View File
@@ -84,7 +84,15 @@ git -C .externals/CLIProxyAPI apply ../../patch/cli-proxy-api-request-lifecycle-
cd .externals/CLIProxyAPI
gofmt -w internal/pluginhost sdk/api/handlers sdk/cliproxy/usage sdk/pluginabi sdk/pluginapi
go test -race ./internal/pluginhost ./sdk/api/handlers ./sdk/cliproxy/usage -count=1
CGO_ENABLED=1 go build -o test-output ./cmd/server
version=v7.2.133-dev
commit=7efe0a7c
build_date="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
CGO_ENABLED=1 go build -buildvcs=false \
-ldflags="-s -w -X main.Version=$version -X main.Commit=$commit -X main.BuildDate=$build_date" \
-o test-output ./cmd/server
help_output="$(./test-output -h 2>&1)"
first_line="${help_output%%$'\n'*}"
test "$first_line" = "CLIProxyAPI Version: $version, Commit: $commit, BuiltAt: $build_date"
rm test-output
```