-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
64 lines (53 loc) · 1.48 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
VERSION_FILE = VERSION
define bump_major
awk -F. '{printf "%s.%s.%s\n", $$1+1, $$2, $$3}' $(VERSION_FILE)
endef
define bump_minor
awk -F. '{printf "%s.%s.%s\n", $$1, $$2+1, $$3}' $(VERSION_FILE)
endef
define bump_patch
awk -F. '{printf "%s.%s.%s\n", $$1, $$2, $$3+1}' $(VERSION_FILE)
endef
# Display this help message
.PHONY: help
help:
@awk '/^.PHONY:/ && (a ~ /#/) {gsub(/.PHONY: /, "", $$0); gsub(/# /, "", a); printf "\033[0;32m%-15s\033[0m%s\n", $$0, a}{a=$$0}' $(MAKEFILE_LIST)
# Check code for errors
.PHONY: check
check:
go vet ./...
# Run unit tests
.PHONY: test
test: check
go test -v -race ./...
# Compile into executable binary
.PHONY: build
build: test
CGO_ENABLED=0 go build -o stars -ldflags "-X main.Version=$(shell cat VERSION)" ./cmd/stars
# Do a release. VERSION needs to be bumped manually
.PHONY: release
release:
git tag v$(shell cat VERSION)
git push origin master
goreleaser --rm-dist
# Do a major release
.PHONY: release-major
release-major:
@echo $(shell $(call bump_major)) > VERSION
@git add VERSION
@git commit -S -m "Release $(shell $(call bump_major))"
$(MAKE) release
# Do a minor release
.PHONY: release-minor
release-minor:
@echo $(shell $(call bump_minor)) > VERSION
@git add VERSION
@git commit -S -m "Release $(shell $(call bump_minor))"
$(MAKE) release
# Do a patch release
.PHONY: release-patch
release-patch:
@echo $(shell $(call bump_patch)) > VERSION
@git add VERSION
@git commit -S -m "Release $(shell $(call bump_patch))"
$(MAKE) release