-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
60 lines (48 loc) · 1.21 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
VERSION=$(shell git tag --contains HEAD | head)
EXTERNAL_TOOLS = \
github.com/Songmu/goxz/cmd/goxz \
github.com/tcnksm/ghr \
github.com/Songmu/ghch/cmd/ghch
BINDIR:=$(CURDIR)/bin
BINNAME?=jarvis
GOCMD=go
GOBUILD=$(GOCMD) build
GOCLEAN=$(GOCMD) clean
GOGENERATE=$(GOCMD) generate
GOTEST=$(GOCMD) test
GOBUILDFLAGS= "-trimpath"
.PHONY: build
build:
$(GOBUILD) -o $(BINDIR)/$(BINNAME) -v $(GOBUILDFLAGS)
.PHONY: devel-deps
devel-deps:
@for tool in $(EXTERNAL_TOOLS) ; do \
echo "Installing $$tool" ; \
GO111MODULE=off go get $$tool; \
done
.PHONY: test
test:
$(GOTEST) -v ./...
.PHONY: generate
generate:
$(GOGENERATE) -v ./...
.PHONY: clean
clean:
$(GOCLEAN)
# release part
.PHONY: validate-version
validate-version:
ifeq ($(strip $(VERSION)),)
$(error Version must be set, please add a tag)
endif
.PHONY: upload
upload: validate-version devel-deps
ghr -v
ghr -body="$$(ghch --latest -F markdown)" v${VERSION} pkg/dist/v${VERSION}
.PHONY: validate-version crossbuild
crossbuild:
goxz -pv=v${VERSION} \
-arch=386,amd64 -d=./pkg/dist/v${VERSION}
cd pkg/dist/v${VERSION} && shasum -a 256 * > ./v${VERSION}_SHASUMS
.PHONY: release
release: validate-version devel-deps crossbuild upload