From 3044db38bb8e26590b02269ee0e308a458321f90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=90=E5=A2=A8?= Date: Wed, 11 Feb 2026 09:58:46 +0800 Subject: [PATCH] =?UTF-8?q?ci:=20=E6=94=B9=E8=BF=9B=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E8=8E=B7=E5=8F=96=E4=BB=A5=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E6=97=A0=E6=A0=87=E7=AD=BE=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修改所有 GitHub Actions 工作流,在检出代码时获取完整历史记录和标签,并将 `git describe` 命令统一添加 `--always` 参数,确保在无标签的提交上也能生成有效的版本信息。 --- .github/workflows/docker-image-amd64.yml | 7 +++++-- .github/workflows/docker-image-arm64.yml | 7 +++++-- .github/workflows/linux-release.yml | 8 ++++---- .github/workflows/macos-release.yml | 4 ++-- .github/workflows/windows-release.yml | 6 +++--- 5 files changed, 19 insertions(+), 13 deletions(-) diff --git a/.github/workflows/docker-image-amd64.yml b/.github/workflows/docker-image-amd64.yml index 0bbf3e1..89a1284 100644 --- a/.github/workflows/docker-image-amd64.yml +++ b/.github/workflows/docker-image-amd64.yml @@ -19,10 +19,13 @@ jobs: steps: - name: Check out the repo uses: actions/checkout@v3 + with: + fetch-depth: 0 + fetch-tags: true - name: Save version info run: | - git describe --tags > VERSION + git describe --tags --always > VERSION - name: Log in to Docker Hub uses: docker/login-action@v2 @@ -51,4 +54,4 @@ jobs: context: . push: true tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file + labels: ${{ steps.meta.outputs.labels }} diff --git a/.github/workflows/docker-image-arm64.yml b/.github/workflows/docker-image-arm64.yml index a25d420..543a352 100644 --- a/.github/workflows/docker-image-arm64.yml +++ b/.github/workflows/docker-image-arm64.yml @@ -19,10 +19,13 @@ jobs: steps: - name: Check out the repo uses: actions/checkout@v3 + with: + fetch-depth: 0 + fetch-tags: true - name: Save version info run: | - git describe --tags > VERSION + git describe --tags --always > VERSION - name: Set up QEMU uses: docker/setup-qemu-action@v2 @@ -58,4 +61,4 @@ jobs: platforms: linux/amd64,linux/arm64 push: true tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file + labels: ${{ steps.meta.outputs.labels }} diff --git a/.github/workflows/linux-release.yml b/.github/workflows/linux-release.yml index 51bae37..570f32d 100644 --- a/.github/workflows/linux-release.yml +++ b/.github/workflows/linux-release.yml @@ -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 }} \ No newline at end of file + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/macos-release.yml b/.github/workflows/macos-release.yml index 9befefe..4b47d64 100644 --- a/.github/workflows/macos-release.yml +++ b/.github/workflows/macos-release.yml @@ -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,7 +32,7 @@ jobs: - name: Build Backend run: | go mod download - go build -ldflags "-X 'message-pusher/common.Version=$(git describe --tags)'" -o message-pusher-macos + go build -ldflags "-X 'message-pusher/common.Version=$(git describe --tags --always)'" -o message-pusher-macos - name: Release uses: softprops/action-gh-release@v1 if: startsWith(github.ref, 'refs/tags/') diff --git a/.github/workflows/windows-release.yml b/.github/workflows/windows-release.yml index 49dd57a..b62435c 100644 --- a/.github/workflows/windows-release.yml +++ b/.github/workflows/windows-release.yml @@ -26,7 +26,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 @@ -35,7 +35,7 @@ jobs: - name: Build Backend run: | go mod download - go build -ldflags "-s -w -X 'message-pusher/common.Version=$(git describe --tags)'" -o message-pusher.exe + go build -ldflags "-s -w -X 'message-pusher/common.Version=$(git describe --tags --always)'" -o message-pusher.exe - name: Release uses: softprops/action-gh-release@v1 if: startsWith(github.ref, 'refs/tags/') @@ -44,4 +44,4 @@ jobs: draft: true generate_release_notes: true env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}