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
+1
View File
@@ -35,6 +35,7 @@
- 本地 CPA 在 WSL 中运行,项目运行目录统一使用 `cpa-plugin/.runtime`Windows 客户端经 `127.0.0.1` 访问 WSL 时,localhost 转发层可能不会立即向 CPA 传递客户端断开,取消链路测试优先在 WSL 内直连执行。
- 从 PowerShell 跨 WSL 或 SSH 执行包含 Bash 变量、命令替换或多层引号的逻辑时,优先在 `.runtime/tmp/` 创建临时脚本后传入目标环境执行,不拼接复杂的单行 shell;临时脚本不提交。
- CLIProxyAPI `v7.2.133` 的宿主补丁保存在 `patch/`,必须按 `usage-context``usage-identity``request-lifecycle-cancel` 的顺序应用;升级 CPA 后先复测补丁是否仍有必要。
- 构建本项目 patched CPA 时必须按上游 release workflow 使用 `-ldflags` 注入 `main.Version``main.Commit``main.BuildDate``Version` 固定使用“当前上游最新 tag + `-dev`”格式(例如 `v7.2.133-dev`),用于明确区分官方 Release 与本项目补丁构建;不得发布只显示 `dev``none``unknown` 的产物。上传前先在本地执行二进制并核对完整版本输出。
- CPA Linux 可执行文件解压后约 60 MiB,`gzip -9` 后约 20 MiB。上传远端时使用 gzip/tar.gz 或 `scp -C`,不要直接传输未压缩二进制;部署后的运行文件仍需解压为原始可执行文件。
- 实际服务器为 `root@akko.pchuan.top`CPA 根目录为 `/root/cpa`。只维护本项目的 `billing` 和已要求启用的 `keeper`,不启用或部署其他参考插件。
- 远端替换 CPA 或 billing 前,先停止 `/root/cpa/cpa.sh` 管理的进程,并把旧二进制、插件和 `data/cpa-ext.db*` 备份到 `/root/cpa/backups/<timestamp>/`;新版本启动失败时恢复旧二进制和插件。
+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
```