-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
52 lines (38 loc) · 1.53 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
# Meta info
NAME := gitflow-release
VERSION := v$(shell cat VERSION)
MAINTAINER := "Vicente Zepeda <[email protected]"
# LD Flags
DATE := $(shell date -u +%Y%m%d.%H%M%S)
COMMIT_ID := $(shell git rev-parse --short HEAD)
GIT_REPO := $(shell git config --get remote.origin.url)
# Go tools flags
LD_FLAGS := -X github.com/chentex/gitflow-release/cmd.buildVersion=$(VERSION)
LD_FLAGS += -X github.com/chentex/gitflow-release/cmd.buildCommit=$(COMMIT_ID)
LD_FLAGS += -X github.com/chentex/gitflow-release/cmd.buildDate=$(DATE)
EXTRA_BUILD_VARS := CGO_ENABLED=0 GOARCH=amd64
SOURCE_DIRS := $(shell go list ./... | grep -v /vendor/)
all: install_dependencies test package-linux package-darwin
lint:
@go fmt $(SOURCE_DIRS)
@go vet $(SOURCE_DIRS)
test: lint
@go test -v $(SOURCE_DIRS) -cover -bench . -race
install_dependencies:
dep ensure
cover:
@bash cover.sh
binaries: binary-darwin binary-linux
binary-darwin:
@-rm -rf build/dist/darwin
@-mkdir -p build/dist/darwin
GOOS=darwin $(EXTRA_BUILD_VARS) go build -ldflags "$(LD_FLAGS)" -o build/dist/darwin/$(NAME)
binary-linux:
@-rm -rf build/dist/linux
@-mkdir -p build/dist/linux
GOOS=linux $(EXTRA_BUILD_VARS) go build -ldflags "$(LD_FLAGS)" -o build/dist/linux/$(NAME)
package-darwin: binary-darwin
@tar -czf build/dist/$(NAME).darwin-amd64.tar.gz -C build/dist/darwin $(NAME)
package-linux: binary-linux
@tar -czf build/dist/$(NAME).linux-amd64.tar.gz -C build/dist/linux $(NAME)
.PHONY: lint test install_dependencies cover binaries binary-darwin binary-linux package-darwin package-linux