-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
52 lines (38 loc) · 1.27 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
49
50
51
52
OUTPUT := _output
BIN := ${OUTPUT}/commitizen
GoVersion := $(word 3, $(shell go version))
GitCommit := $(shell git rev-parse --short HEAD)
BuildTime := $(shell date "+%Y-%m-%d %H:%M:%S")
GitVersion := $(shell git tag | tail -1)
VERSION_PACKAGE := github.com/robertzhangwenjie/commitizen/pkg/version
GIT_TREE_STATE=dirty
ifeq (, $(shell git status --porcelain 2>/dev/null))
GIT_TREE_STATE=clean
endif
export GoVersion GitCommit PACKAGE_VERSION GIT_TREE_STATE BuildTime GitVersion
# build args
GO_BUILD_FLAGS += -ldflags "-X '${VERSION_PACKAGE}.GitCommit=${GitCommit}' \
-X '${VERSION_PACKAGE}.BuildTime=${BuildTime}' \
-X '${VERSION_PACKAGE}.GoVersion=${GoVersion}' \
-X '${VERSION_PACKAGE}.GitTreeState=${GIT_TREE_STATE}' \
-X '${VERSION_PACKAGE}.GitVersion=${GitVersion}'"
clean:
@echo "========> Cleaning all build output"
@rm -rvf ${OUTPUT}
install: build
${BIN} install
.PHONY: commit
commit:
@go run main.go
build: clean
@echo "========> Building binary"
go build ${GO_BUILD_FLAGS} -o ${BIN}
build.multiarch:
@goreleaser build --snapshot --rm-dist
dryRun: build
@${BIN} --dry-run
test:
@echo "========> Running all tests"
@go test ./... -v
test.coverage:
@go test ./... -v -coverprofile=coverage.out