forked from rumyantseva/go-zeroservice
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
42 lines (34 loc) · 951 Bytes
/
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
APP?=app
RELEASE?=1.0.0
GOOS?=linux
COMMIT?=$(shell git rev-parse --short HEAD)
BUILD_TIME?=$(shell date -u '+%Y-%m-%d_%H:%M:%S')
.PHONY: check
check: prepare_metalinter
gometalinter --vendor ./...
.PHONY: build
build: clean
CGO_ENABLED=0 GOOS=${GOOS} go build \
-ldflags "-X main.version=${RELEASE} -X main.commit=${COMMIT} -X main.buildTime=${BUILD_TIME}" \
-o bin/${GOOS}/${APP}
.PHONY: clean
clean:
@rm -f bin/${GOOS}/${APP}
.PHONY: vendor
vendor: prepare_dep
dep ensure
HAS_DEP := $(shell command -v dep;)
HAS_METALINTER := $(shell command -v gometalinter;)
.PHONY: prepare_dep
prepare_dep:
ifndef HAS_DEP
go get -u -v -d github.com/golang/dep/cmd/dep && \
go install -v github.com/golang/dep/cmd/dep
endif
.PHONY: prepare_metalinter
prepare_metalinter:
ifndef HAS_METALINTER
go get -u -v -d github.com/alecthomas/gometalinter && \
go install -v github.com/alecthomas/gometalinter && \
gometalinter --install --update
endif