File tree 4 files changed +904
-15
lines changed
4 files changed +904
-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
15
15
.PHONY : all test coverage
16
16
all : test coverage build
17
17
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
+
18
27
build :
19
- $(GOBUILD ) .
28
+ $(GOBUILD ) -ldflags= " -X 'main.GitSHA1= $( GIT_SHA ) ' -X 'main.GitDirty= $( GIT_DIRTY ) ' " .
20
29
21
30
build-race :
22
- $(GOBUILDRACE ) .
31
+ $(GOBUILDRACE ) -ldflags= " -X 'main.GitSHA1= $( GIT_SHA ) ' -X 'main.GitDirty= $( GIT_DIRTY ) ' " .
23
32
24
33
checkfmt :
25
34
@echo ' Checking gofmt' ; \
@@ -48,7 +57,9 @@ coverage: get test
48
57
release :
49
58
$(GOGET ) github.com/mitchellh/gox
50
59
$(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) '" .
52
63
53
64
publish : release
54
65
@for f in $(shell ls ${DISTDIR}) ; \
You can’t perform that action at this time.
0 commit comments