-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
50 lines (37 loc) · 1.1 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
BINARY = gcp-gpu-metrics
LAST_COMMIT = `git rev-parse HEAD`
VERSION_PKG = main
MAIN_LOCATION = ./
VERSION := $(shell git describe --exact-match --abbrev=0 --tags $(git rev-list --tags --max-count=1) 2> /dev/null)
ifndef VERSION
VERSION = $(shell git describe --abbrev=3 --tags $(git rev-list --tags --max-count=1))-dev
endif
.PHONY: all
all: ${BINARY}
${BINARY}:
@echo " > Build ${BINARY} binary < "
GO111MODULE=on go build -mod=vendor -ldflags "-X ${VERSION_PKG}.Commit=${LAST_COMMIT} -X ${VERSION_PKG}.Version=${VERSION}" \
-o ${BINARY} ${MAIN_LOCATION}
.PHONY: lint
lint:
@echo " > Lint Go code < "
golint -set_exit_status ./*.go
.PHONY: clean
clean:
@echo " > Delete ${BINARY} binary < "
rm -f ${BINARY}
.PHONY: re
re: clean all
define GORELEASER_COMMAND
VERSION_PKG=${VERSION_PKG} VERSION=${VERSION} \
LAST_COMMIT=${LAST_COMMIT} goreleaser
endef
.PHONY: goreleaser
goreleaser:
ifneq (,$(findstring -dev,$(VERSION)))
@echo Run Goreleaser in snapshot mod
${GORELEASER_COMMAND} --snapshot --rm-dist
else
@echo Run Goreleaser in release mod
${GORELEASER_COMMAND} release --rm-dist
endif