feat: 更新版本管理逻辑,支持通过标签版本注入,修改版本常量为可变变量

This commit is contained in:
ryan
2026-03-10 23:06:36 +08:00
parent 6fe9ad4af6
commit e5c01f12be
3 changed files with 9 additions and 4 deletions
+7 -2
View File
@@ -23,7 +23,11 @@ jobs:
- name: Resolve version metadata
id: version
run: |
VERSION="$(git describe --tags)"
if [[ "${GITHUB_REF}" == refs/tags/* ]]; then
VERSION="${GITHUB_REF_NAME}"
else
VERSION="$(git describe --tags)"
fi
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
if [[ "$VERSION" =~ ^v[0-9]+(\.[0-9]+)*$ ]]; then
echo "is_prerelease=false" >> "$GITHUB_OUTPUT"
@@ -164,10 +168,11 @@ jobs:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
ASSET_NAME: ${{ matrix.asset_name }}
VERSION: ${{ needs.prepare.outputs.version }}
run: |
go mod download
mkdir -p ../dist
go build -trimpath -ldflags "-s -w" -o "../dist/$ASSET_NAME" ./cmd/agent
go build -trimpath -ldflags "-s -w -X 'atsflare-agent/internal/config.AgentVersion=$VERSION'" -o "../dist/$ASSET_NAME" ./cmd/agent
- name: Upload Agent Artifact
uses: actions/upload-artifact@v4
+1 -1
View File
@@ -1,3 +1,3 @@
package config
const AgentVersion = "0.3.0"
var AgentVersion = "0.3.0"
+1 -1
View File
@@ -8,7 +8,7 @@ import (
)
var StartTime = time.Now().Unix() // unit: second
var Version = "v0.2.0" // this hard coding will be replaced automatically when building, no need to manually change
var Version = "dev" // release builds inject the tag version via ldflags
var SystemName = "ATSFlare"
var ServerAddress = "http://localhost:3000"
var Footer = ""