ci: 改进版本信息获取以支持无标签提交

修改所有 GitHub Actions 工作流,在检出代码时获取完整历史记录和标签,并将 `git describe` 命令统一添加 `--always` 参数,确保在无标签的提交上也能生成有效的版本信息。
This commit is contained in:
2026-02-11 09:58:46 +08:00
parent 79f8d5d600
commit 3044db38bb
5 changed files with 19 additions and 13 deletions
+4 -4
View File
@@ -23,7 +23,7 @@ jobs:
run: |
cd web
npm install
REACT_APP_VERSION=$(git describe --tags) npm run build
REACT_APP_VERSION=$(git describe --tags --always) npm run build
cd ..
- name: Set up Go
uses: actions/setup-go@v3
@@ -32,12 +32,12 @@ jobs:
- name: Build Backend (amd64)
run: |
go mod download
go build -ldflags "-s -w -X 'message-pusher/common.Version=$(git describe --tags)' -extldflags '-static'" -o message-pusher
go build -ldflags "-s -w -X 'message-pusher/common.Version=$(git describe --tags --always)' -extldflags '-static'" -o message-pusher
- name: Build Backend (arm64)
run: |
sudo apt-get update
sudo apt-get install gcc-aarch64-linux-gnu
CC=aarch64-linux-gnu-gcc CGO_ENABLED=1 GOOS=linux GOARCH=arm64 go build -ldflags "-s -w -X 'message-pusher/common.Version=$(git describe --tags)' -extldflags '-static'" -o message-pusher-arm64
CC=aarch64-linux-gnu-gcc CGO_ENABLED=1 GOOS=linux GOARCH=arm64 go build -ldflags "-s -w -X 'message-pusher/common.Version=$(git describe --tags --always)' -extldflags '-static'" -o message-pusher-arm64
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
@@ -48,4 +48,4 @@ jobs:
draft: true
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}