Skip to content

Commit 900deca

Browse files
xiantangclaude
andauthored
fix: stamp a real version into the docker latest image (#930)
The push_to_docker_latest job had no checkout step, so docker/build-push-action built from the remote Git context, which BuildKit materializes without a .git directory. Inside the image `git describe --tags` then failed with "fatal: not a git repository" and main.airVersion was stamped empty, and hack/check.sh's `git diff --cached` failed the same way. Check out the repo with full history and build from the local context so git works, and fall back to "dev" in the Makefile so any other git-less build still produces a usable version string. Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
1 parent 208af6c commit 900deca

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

.github/workflows/build.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,13 @@ jobs:
7373
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
7474
runs-on: ubuntu-latest
7575
steps:
76+
# Without a checkout, build-push-action builds from the remote Git
77+
# context, which has no .git directory, so `git describe --tags` inside
78+
# the image cannot stamp a version. Fetch tags for the same reason.
79+
- name: Check out code
80+
uses: actions/checkout@v4
81+
with:
82+
fetch-depth: 0
7683
- name: Set up QEMU
7784
uses: docker/setup-qemu-action@v3
7885
- name: Set up Docker Buildx
@@ -92,6 +99,7 @@ jobs:
9299
id: docker_build
93100
uses: docker/build-push-action@v5
94101
with:
102+
context: .
95103
push: true
96104
platforms: linux/amd64,linux/arm64
97105
tags: |

Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
AIRVER := $(shell git describe --tags)
1+
# Builds outside a git checkout (e.g. a Docker build context without .git) have
2+
# no tags to describe, so fall back instead of stamping an empty version.
3+
AIRVER ?= $(shell git describe --tags 2>/dev/null || echo dev)
24
LDFLAGS += -X "main.BuildTimestamp=$(shell date -u "+%Y-%m-%d %H:%M:%S")"
35
LDFLAGS += -X "main.airVersion=$(AIRVER)"
46
LDFLAGS += -X "main.goVersion=$(shell go version | sed -r 's/go version go(.*)\ .*/\1/')"

0 commit comments

Comments
 (0)