-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
37 lines (30 loc) · 1.57 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
PKGS := $(shell go list ./... | grep -v /vendor)
GO_FILES := $(shell find . -iname '*.go' -type f | grep -v /vendor/) # All the .go files, excluding vendor/
BUILD_DATE := $(shell date -u +'%Y-%m-%dT%H:%M:%S')
VERSION ?= latest
LDFLAGS := -s -w -X github.com/dtchanpura/deployment-agent/constants.Version=$(VERSION) -X github.com/dtchanpura/deployment-agent/constants.BuildDateStr=$(BUILD_DATE)
BINARY := deployment-agent
PLATFORMS := windows linux darwin
os = $(word 1, $@)
bootstrap:
go install golang.org/x/lint/golint@latest # Linter
go install honnef.co/go/tools/cmd/staticcheck@latest # Badass static analyzer/linter
# go install honnef.co/go/tools/cmd/megacheck@latest # Badass static analyzer/linter
go install github.com/fzipp/gocyclo/cmd/gocyclo@latest # Cyclomatic complexity check
go mod download
test:
go test -v -race $(PKGS) # Normal Test
go vet ./... # go vet is the official Go static analyzer
staticcheck ./... # "go vet on steroids" + linter
gocyclo -over 19 $(GO_FILES) # forbid code with huge functions
golint -set_exit_status $(PKGS) # one last linter
$(PLATFORMS):
mkdir -p release
CGO_ENABLED=0 GOOS=$(os) GOARCH=amd64 go build -o release/$(BINARY) -ldflags="$(LDFLAGS)"
tar -czvf release/$(BINARY)-$(VERSION)-$(os)-amd64.tar.gz README.md -C release/ $(BINARY)
CGO_ENABLED=0 GOOS=$(os) GOARCH=arm64 go build -o release/$(BINARY) -ldflags="$(LDFLAGS)"
tar -czvf release/$(BINARY)-$(VERSION)-$(os)-arm64.tar.gz README.md -C release/ $(BINARY)
.PHONY: release
release: windows linux darwin
clean:
rm -rf release/*