diff --git a/.gitea/workflows/cd.yml b/.gitea/workflows/cd.yml index 85d4c57..519443a 100644 --- a/.gitea/workflows/cd.yml +++ b/.gitea/workflows/cd.yml @@ -60,7 +60,11 @@ jobs: run: | REGISTRY="localhost:5000" REF="${REGISTRY}/${{ env.IMAGE }}:${{ steps.meta.outputs.sha-tag }}" + # Stamp the real build version: the git tag on a v* build, else the short sha. + VERSION="${{ steps.meta.outputs.version-tag }}" + [ -z "$VERSION" ] && VERSION="${{ steps.meta.outputs.sha-tag }}" buildah build \ + --build-arg VERSION="${VERSION}" \ --label "org.opencontainers.image.revision=${{ github.sha }}" \ --label "org.opencontainers.image.source=${{ github.repositoryUrl }}" \ -t ${REF} \ diff --git a/Dockerfile b/Dockerfile index 22b4927..2bd2f30 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,7 +14,10 @@ ENV GOSUMDB=off COPY go.mod go.sum ./ RUN go mod download COPY . . -RUN CGO_ENABLED=0 go build -trimpath -ldflags='-s -w' -o /out/gitea-mcp ./cmd/gitea-mcp +# Build version stamped in by CI (--build-arg VERSION=); defaults to +# "dev" for a plain `docker build` (#47). +ARG VERSION=dev +RUN CGO_ENABLED=0 go build -trimpath -ldflags="-s -w -X main.version=${VERSION}" -o /out/gitea-mcp ./cmd/gitea-mcp FROM gcr.io/distroless/static-debian12:nonroot COPY --from=build /out/gitea-mcp /gitea-mcp