mirror of
https://github.com/shadow1ng/fscan.git
synced 2026-09-25 20:51:52 +08:00
fix(ci): 修复版本注入和CI触发配置
- goreleaser ldflags 指向正确的包路径 common.version/commit/date - version 改为 var 支持 ldflags 注入,banner 显示 commit 和构建日期 - test-build 触发分支增加 dev-* 通配
This commit is contained in:
@@ -23,7 +23,7 @@ builds:
|
|||||||
- goos: windows
|
- goos: windows
|
||||||
goarch: arm64
|
goarch: arm64
|
||||||
flags: [-trimpath]
|
flags: [-trimpath]
|
||||||
ldflags: -s -w -X main.version={{ .Version }} -X main.commit={{ .ShortCommit }} -X main.date={{ .Date }} -X main.builtBy=goreleaser
|
ldflags: -s -w -X github.com/shadow1ng/fscan/common.version={{ .Version }} -X github.com/shadow1ng/fscan/common.commit={{ .ShortCommit }} -X github.com/shadow1ng/fscan/common.date={{ .Date }}
|
||||||
mod_timestamp: "{{ .CommitTimestamp }}"
|
mod_timestamp: "{{ .CommitTimestamp }}"
|
||||||
|
|
||||||
# 无本地插件版 - 排除本地模块
|
# 无本地插件版 - 排除本地模块
|
||||||
@@ -42,7 +42,7 @@ builds:
|
|||||||
goarch: arm64
|
goarch: arm64
|
||||||
flags: [-trimpath]
|
flags: [-trimpath]
|
||||||
tags: [no_local]
|
tags: [no_local]
|
||||||
ldflags: -s -w -X main.version={{ .Version }} -X main.commit={{ .ShortCommit }} -X main.date={{ .Date }} -X main.builtBy=goreleaser
|
ldflags: -s -w -X github.com/shadow1ng/fscan/common.version={{ .Version }} -X github.com/shadow1ng/fscan/common.commit={{ .ShortCommit }} -X github.com/shadow1ng/fscan/common.date={{ .Date }}
|
||||||
mod_timestamp: "{{ .CommitTimestamp }}"
|
mod_timestamp: "{{ .CommitTimestamp }}"
|
||||||
|
|
||||||
# WebUI版 - 带Web管理界面
|
# WebUI版 - 带Web管理界面
|
||||||
@@ -61,7 +61,7 @@ builds:
|
|||||||
goarch: arm64
|
goarch: arm64
|
||||||
flags: [-trimpath]
|
flags: [-trimpath]
|
||||||
tags: [web]
|
tags: [web]
|
||||||
ldflags: -s -w -X main.version={{ .Version }} -X main.commit={{ .ShortCommit }} -X main.date={{ .Date }} -X main.builtBy=goreleaser
|
ldflags: -s -w -X github.com/shadow1ng/fscan/common.version={{ .Version }} -X github.com/shadow1ng/fscan/common.commit={{ .ShortCommit }} -X github.com/shadow1ng/fscan/common.date={{ .Date }}
|
||||||
mod_timestamp: "{{ .CommitTimestamp }}"
|
mod_timestamp: "{{ .CommitTimestamp }}"
|
||||||
|
|
||||||
upx:
|
upx:
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ on:
|
|||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- dev
|
- dev
|
||||||
|
- dev-*
|
||||||
- develop
|
- develop
|
||||||
- feature/*
|
- feature/*
|
||||||
paths-ignore:
|
paths-ignore:
|
||||||
|
|||||||
+6
-3
@@ -69,12 +69,15 @@ func Banner() {
|
|||||||
fmt.Println(bottomBorder)
|
fmt.Println(bottomBorder)
|
||||||
|
|
||||||
// 打印版本信息
|
// 打印版本信息
|
||||||
|
versionStr := fmt.Sprintf(" Fscan %s (%s %s)", version, commit, date)
|
||||||
|
if commit == "unknown" {
|
||||||
|
versionStr = fmt.Sprintf(" Fscan %s", version)
|
||||||
|
}
|
||||||
if flagVars.NoColor {
|
if flagVars.NoColor {
|
||||||
// 无色彩模式下使用普通文本
|
fmt.Printf("%s\n\n", versionStr)
|
||||||
fmt.Printf(" Fscan Version: %s\n\n", version)
|
|
||||||
} else {
|
} else {
|
||||||
c := color.New(colors[1])
|
c := color.New(colors[1])
|
||||||
_, _ = c.Printf(" Fscan Version: %s\n\n", version)
|
_, _ = c.Printf("%s\n\n", versionStr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+6
-1
@@ -60,7 +60,12 @@ const (
|
|||||||
LogLevelBaseInfoSuccess = "base,info,success"
|
LogLevelBaseInfoSuccess = "base,info,success"
|
||||||
)
|
)
|
||||||
|
|
||||||
const version = "2.1.1"
|
// 版本信息,通过 ldflags 注入
|
||||||
|
var (
|
||||||
|
version = "2.1.1"
|
||||||
|
commit = "unknown"
|
||||||
|
date = "unknown"
|
||||||
|
)
|
||||||
|
|
||||||
// 运行时数据已迁移到Config对象中,使用GetGlobalConfig()访问
|
// 运行时数据已迁移到Config对象中,使用GetGlobalConfig()访问
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user