From 8c4fc3e75a3d274a0b569229619bd5f504a2b634 Mon Sep 17 00:00:00 2001 From: Tobias Spieth Date: Fri, 27 Mar 2020 08:41:14 +0100 Subject: [PATCH] cmd/shfmt: build with latest git tag as version Instead of a fixed string as version for development releases, this injects the latest git tag as version during build and thus allows to identify the binary later. Fixes #519. --- cmd/shfmt/Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cmd/shfmt/Dockerfile b/cmd/shfmt/Dockerfile index 3085bb77e..fb0b69d5c 100644 --- a/cmd/shfmt/Dockerfile +++ b/cmd/shfmt/Dockerfile @@ -2,7 +2,8 @@ FROM golang:1.14-alpine3.11 AS build WORKDIR /src COPY . . -RUN CGO_ENABLED=0 go build -ldflags '-w -s -extldflags "-static"' ./cmd/shfmt +RUN apk add git +RUN CGO_ENABLED=0 go build -ldflags "-w -s -extldflags '-static' -X main.version=$(git describe --always --dirty)" ./cmd/shfmt FROM alpine:3.11 AS alpine COPY --from=build /src/shfmt /bin/shfmt