File tree Expand file tree Collapse file tree 4 files changed +905
-15
lines changed
Expand file tree Collapse file tree 4 files changed +905
-15
lines changed Original file line number Diff line number Diff line change @@ -15,11 +15,20 @@ DIST_OS_ARCHS = "linux/amd64 linux/arm64 windows/amd64 darwin/amd64 darwin/arm64
1515.PHONY : all test coverage
1616all : test coverage build
1717
18+ # Build-time GIT variables
19+ ifeq ($(GIT_SHA ) ,)
20+ GIT_SHA: =$(shell git rev-parse HEAD)
21+ endif
22+
23+ ifeq ($(GIT_DIRTY ) ,)
24+ GIT_DIRTY: =$(shell git diff --no-ext-diff 2> /dev/null | wc -l)
25+ endif
26+
1827build :
19- $(GOBUILD ) .
28+ $(GOBUILD ) -ldflags= " -X 'main.GitSHA1= $( GIT_SHA ) ' -X 'main.GitDirty= $( GIT_DIRTY ) ' " .
2029
2130build-race :
22- $(GOBUILDRACE ) .
31+ $(GOBUILDRACE ) -ldflags= " -X 'main.GitSHA1= $( GIT_SHA ) ' -X 'main.GitDirty= $( GIT_DIRTY ) ' " .
2332
2433checkfmt :
2534 @echo ' Checking gofmt' ; \
@@ -48,7 +57,9 @@ coverage: get test
4857release :
4958 $(GOGET ) github.com/mitchellh/gox
5059 $(GOGET ) github.com/tcnksm/ghr
51- GO111MODULE=on gox -osarch ${DIST_OS_ARCHS} -output " ${DISTDIR} /${BIN_NAME} _{{.OS}}_{{.Arch}}" .
60+ GO111MODULE=on gox -osarch ${DIST_OS_ARCHS} \
61+ -output " ${DISTDIR} /${BIN_NAME} _{{.OS}}_{{.Arch}}" \
62+ -ldflags=" -X 'main.GitSHA1=$( GIT_SHA) ' -X 'main.GitDirty=$( GIT_DIRTY) '" .
5263
5364publish : release
5465 @for f in $(shell ls ${DISTDIR}) ; \
You can’t perform that action at this time.
0 commit comments