-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
96 lines (74 loc) · 2.34 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
.PHONY: help
.DEFAULT: help
ifndef VERBOSE
.SILENT:
endif
NO_COLOR=\033[0m
GREEN=\033[32;01m
YELLOW=\033[33;01m
RED=\033[31;01m
VER?=dev
GHASH:=$(shell git rev-parse --short HEAD)
VERSION?=$(shell git describe --tags --always --dirty --match=v* 2> /dev/null || echo v0)
GOTELEMETRY:= off
GO:= go
GO_BUILD:= go build -mod vendor -ldflags "-s -w -X main.GitCommit=${GHASH} -X main.Version=${VERSION}"
#VERSION="${VERSION}" goreleaser --snapshot --rm-dist
GO_VENDOR:= go mod vendor
BIN:= react
help:: ## Show this help
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[33m%-20s\033[0m %s\n", $$1, $$2}'
$(BIN): vendor ## Produce binary
GO111MODULE=on $(GO_BUILD)
# We always want vendor to run
.PHONY: vendor
vendor: **/*.go ## Build vendor deps
GO111MODULE=on $(GO_VENDOR)
clean: clean-vendor ## Clean artefacts
rm -rf $(BIN) $(BIN)_* $(BIN).exe dist/
clean-vendor: ## Clean vendor folder
rm -rf vendor
clean-cache: ## Clean Golang mod cache
go clean --modcache
build: clean $(BIN) ## Build binary
upx $(BIN)
run:
go run .
snapshot: clean ## Build local snapshot
goreleaser build --snapshot --clean
dev: clean ## Dev test target
go build -ldflags "-s -w -X main.Version=${VER}" -o $(BIN)
upx $(BIN)
test: vendor ## Run tests
go test -v ./...
fmt: **/*.go ## Formt Golang code
go fmt ./...
lint:
golint ./...
vet:
go vet -all ./...
$(BIN)_linux_amd64: vendor **/*.go
GOOS=linux GOARCH=amd64 CGO_ENABLED=1 go build -o $@ *.go
upx $@
$(BIN)_linux_alpine: vendor **/*.go
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o $@ *.go
upx $@
$(BIN)_darwin_amd64: vendor **/*.go
GOOS=darwin go build -o $@ *.go
upx $@
$(BIN)_windows_amd64.exe: vendor **/*.go
GOOS=windows GOARCH=amd64 go build -o $@ *.go
upx $@
pack: $(BIN)_linux_amd64 $(BIN)_darwin_amd64 $(BIN)_windows_amd64.exe
zip $(BIN)_linux_amd64.zip $(BIN)_linux_amd64
zip $(BIN)_darwin_amd64.zip $(BIN)_darwin_amd64
zip $(BIN)_windows_amd64.zip $(BIN)_windows_amd64.exe
fmtcheck: vendor **/*.go ## Check formatting
@gofmt_files=$$(gofmt -l `find . -name '*.go' | grep -v vendor`); \
if [ -n "$${gofmt_files}" ]; then \
echo 'gofmt needs running on the following files:'; \
echo "$${gofmt_files}"; \
echo "You can use the command: \`make fmt\` to reformat code."; \
exit 1; \
fi; \
exit 0