Skip to content

Commit

Permalink
Ensure version is set for all builds
Browse files Browse the repository at this point in the history
  • Loading branch information
prymitive committed Jan 27, 2022
1 parent 03d6505 commit f954467
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
FROM golang:1.17.6-alpine
COPY . /src
WORKDIR /src
RUN go build ./cmd/pint
RUN apk add make git
RUN make

FROM debian:stable
RUN apt-get update --yes && \
Expand Down
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
PINT_BIN := pint
PINT_GO_DIRS := cmd internal
PINT_SRC := $(shell find $(PINT_GO_DIRS) -type f -name '*.go')
PINT_VERSION ?= $(shell git describe --tags --always --dirty='-dev')
PINT_COMMIT ?= $(shell git rev-parse HEAD)

GOBIN := $(shell go env GOBIN)
ifeq ($(GOBIN),)
Expand All @@ -14,7 +16,7 @@ COVER_PROFILE = $(COVER_DIR)/coverage.out
build: $(PINT_BIN)

$(PINT_BIN): $(PINT_SRC) go.mod go.sum
go build -trimpath -ldflags='-s -w' ./cmd/pint
CGO_ENABLED=0 go build -trimpath -ldflags='-X main.version=$(PINT_VERSION) -X main.commit=$(PINT_COMMIT) -s -w' ./cmd/pint

$(GOBIN)/golangci-lint: tools/golangci-lint/go.mod tools/golangci-lint/go.sum
go install -modfile=tools/golangci-lint/go.mod github.com/golangci/golangci-lint/cmd/golangci-lint
Expand Down

0 comments on commit f954467

Please sign in to comment.