-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathMakefile
57 lines (46 loc) · 1.69 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
GOFILES = $(shell find . -name '*.go' -not -path './vendor/*')
GOPACKAGES_UNIT = $(shell go list ./... | grep -v /vendor/ | grep -v integration_test)
GIT_DESCR = $(shell git describe --tags --always)
APP=aecli
OUTPUTFOLDER = dist
ARCH = amd64
default: build
build: $(GOFILES)
@echo build binary to $(OUTPUTFOLDER)
CGO_ENABLED=0 go build -ldflags "-X main.Version=$(GIT_DESCR)" -o $(OUTPUTFOLDER)/$(APP) .
@echo copy resources
cp -r README.md LICENSE $(OUTPUTFOLDER)
@echo done
build-release:
@echo build binary to $(OUTPUTFOLDER)
$(eval OS=darwin)
GOOS=$(OS) GOARCH=$(ARCH) CGO_ENABLED=0 go build -ldflags "-X main.Version=$(GIT_DESCR)" -o $(OUTPUTFOLDER)/$(OS)/$(APP) .
cp -r README.md LICENSE CHANGELOG.md $(OUTPUTFOLDER)/$(OS)
zip -r $(OUTPUTFOLDER)/$(OS).zip $(OUTPUTFOLDER)/$(OS)
$(eval OS=windows)
GOOS=$(OS) GOARCH=$(ARCH) CGO_ENABLED=0 go build -ldflags "-X main.Version=$(GIT_DESCR)" -o $(OUTPUTFOLDER)/$(OS)/$(APP).exe .
cp -r README.md LICENSE CHANGELOG.md $(OUTPUTFOLDER)/$(OS)
zip -r $(OUTPUTFOLDER)/$(OS).zip $(OUTPUTFOLDER)/$(OS)
$(eval OS=linux)
GOOS=$(OS) GOARCH=$(ARCH) CGO_ENABLED=0 go build -ldflags "-X main.Version=$(GIT_DESCR)" -o $(OUTPUTFOLDER)/$(OS)/$(APP) .
cp -r README.md LICENSE CHANGELOG.md $(OUTPUTFOLDER)/$(OS)
zip -r $(OUTPUTFOLDER)/$(OS).zip $(OUTPUTFOLDER)/$(OS)
@echo done
test: test-unit test-integration
test-unit:
go test -v $(GOPACKAGES_UNIT)
test-integration:
go test -v ./integration_test
bench:
go test -bench -v ./...
lint:
staticcheck ./...
install: build
@cp $(OUTPUTFOLDER)/$(APP) $(GOPATH)/bin
@echo copied to GOPATH/bin
clean:
@echo remove $(OUTPUTFOLDER) folder
@rm -rf $(OUTPUTFOLDER)
@echo done
changelog:
git-chglog -o CHANGELOG.md