feat(build): 支持 build tag 版本注入并清理历史二进制
- ./run.sh build 仅输出项目根目录 ./aiops,构建前清理 backend/aiops-* - 新增 ./run.sh build tag v1.0.1,通过 ldflags 注入 Version/BuildTime/GitCommit - 支持 ./aiops version 子命令查看编译版本 - 删除误提交的 backend/aiops-cgo,gitignore 忽略 backend/aiops-*
This commit is contained in:
1 parent
1fd9a631e5
commit
8be51ac514
4 files changed
+67
-16
No files matched your search
+18
-4
@@ -83,16 +83,30 @@ var (
|
||||
// @name Authorization
|
||||
// @description Type "Bearer" followed by a space and JWT token.
|
||||
|
||||
// printVersion 输出编译时注入的版本信息 // Logan.Li
|
||||
func printVersion() {
|
||||
fmt.Printf("AIOps 智能运维平台\n")
|
||||
fmt.Printf(" 版本: %s\n", Version)
|
||||
fmt.Printf(" 构建: %s\n", BuildTime)
|
||||
fmt.Printf(" 提交: %s\n", GitCommit)
|
||||
}
|
||||
|
||||
func main() {
|
||||
// 支持 ./aiops version 子命令(无需启动服务)// Logan.Li
|
||||
if len(os.Args) > 1 {
|
||||
switch os.Args[1] {
|
||||
case "version", "-v", "--version":
|
||||
printVersion()
|
||||
os.Exit(0)
|
||||
}
|
||||
}
|
||||
|
||||
// 解析 CLI 参数 // Logan.Li
|
||||
flag.Parse()
|
||||
|
||||
// 显示版本信息 // Logan.Li
|
||||
if *flagVersion {
|
||||
fmt.Printf("AIOps 智能运维平台\n")
|
||||
fmt.Printf(" 版本: %s\n", Version)
|
||||
fmt.Printf(" 构建: %s\n", BuildTime)
|
||||
fmt.Printf(" 提交: %s\n", GitCommit)
|
||||
printVersion()
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user