refactor(cli): 将 cobra 替换为 urfave/cli v3 并添加版本号注入
All checks were successful
ci/woodpecker/tag/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/tag/woodpecker Pipeline was successful
- 移除 cobra 依赖,使用更轻量的 urfave/cli v3 - 删除 cmd/root.go,将 CLI 逻辑整合到 main.go - 添加编译时版本号注入(Version 和 Commit) - 适配 .woodpecker.yml 以支持新的版本号路径 - 代码从 147 行减少到 135 行(净减少 12 行) 版本号现在通过 ldflags 在编译时注入,不再硬编码。 CI 构建时会自动从 Git tag 和 commit SHA 注入版本信息。
This commit is contained in:
@@ -23,9 +23,9 @@ steps:
|
||||
- apt-get install -y libasound2-dev:arm64 libvlc-dev:arm64
|
||||
- mkdir -p release
|
||||
# 构建 amd64 (native)
|
||||
- PKG_CONFIG_PATH=/usr/lib/x86_64-linux-gnu/pkgconfig go build -ldflags="-w -s" -o release/game-driver-linux-amd64 .
|
||||
- PKG_CONFIG_PATH=/usr/lib/x86_64-linux-gnu/pkgconfig go build -ldflags="-w -s -X main.Version=${CI_COMMIT_TAG} -X main.Commit=${CI_COMMIT_SHA}" -o release/game-driver-linux-amd64 .
|
||||
# 构建 arm64 (cross-compile)
|
||||
- PKG_CONFIG_PATH=/usr/lib/aarch64-linux-gnu/pkgconfig GOOS=linux GOARCH=arm64 CGO_ENABLED=1 CC=aarch64-linux-gnu-gcc go build -ldflags="-w -s" -o release/game-driver-linux-arm64 .
|
||||
- PKG_CONFIG_PATH=/usr/lib/aarch64-linux-gnu/pkgconfig GOOS=linux GOARCH=arm64 CGO_ENABLED=1 CC=aarch64-linux-gnu-gcc go build -ldflags="-w -s -X main.Version=${CI_COMMIT_TAG} -X main.Commit=${CI_COMMIT_SHA}" -o release/game-driver-linux-arm64 .
|
||||
- ls -lh release/
|
||||
|
||||
# 发布构建产物(可选)
|
||||
|
||||
Reference in New Issue
Block a user