Skip to content

Commit

Permalink
cmd/shfmt: build with latest git tag as version
Browse files Browse the repository at this point in the history
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 mvdan#519.
  • Loading branch information
spieth committed Mar 27, 2020
1 parent 8bfaa27 commit 1eea4d6
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion cmd/shfmt/Dockerfile
Expand Up @@ -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
Expand Down

0 comments on commit 1eea4d6

Please sign in to comment.