-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
79 lines (58 loc) · 2.86 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
PROJECT=forkdetector
ORGANISATION=wavesplatform
MODULE=github.com/$(ORGANISATION)/$(PROJECT)
SOURCE=$(shell find . -name '*.go' | grep -v vendor/)
VERSION=$(shell git describe --tags --always --dirty)
export GO111MODULE=on
.PHONY: vendor vetcheck fmtcheck clean build gotest update-go-deps
all: vendor vet-check fmt-check go-test mod-clean
ci: vendor vet-check fmt-check release go-test-race-coverage mod-clean
ver:
@echo Building version: $(VERSION)
go-test:
go test -cover $$(go list ./...)
go-test-race-coverage:
go test -timeout 20m -race -coverprofile=coverage.txt -covermode=atomic $$(go list ./...)
fmt-check:
@gofmt -l -s . | grep ".*\.go" | grep -v vendor/; if [ "$$?" = "0" ]; then exit 1; fi
mod-clean:
go mod tidy
update-go-deps: mod-clean
@echo ">> updating Go dependencies"
@for m in $$(go list -mod=readonly -m -f '{{ if and (not .Indirect) (not .Main)}}{{.Path}}{{end}}' all); do \
go get $$m; \
done
go mod tidy
ifneq (,$(wildcard vendor))
go mod vendor
endif
clean:
@rm -rf build
go mod tidy
vendor:
go mod vendor
vet-check:
go vet ./...
golangci-lint run -c .golangci-strict.yml
build-linux-amd64:
@CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o build/bin/linux-amd64/forkdetector -ldflags="-X github.com/alexeykiselev/waves-fork-detector/version.version=$(VERSION)" .
build-linux-arm64:
@CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -o build/bin/linux-arm64/forkdetector -ldflags="-X github.com/alexeykiselev/waves-fork-detector/version.version=$(VERSION)" .
build-darwin-amd64:
@CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -o build/bin/darwin-amd64/forkdetector -ldflags="-X github.com/alexeykiselev/waves-fork-detector/version.version=$(VERSION)" .
build-darwin-arm64:
@CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -o build/bin/darwin-arm64/forkdetector -ldflags="-X github.com/alexeykiselev/waves-fork-detector/version.version=$(VERSION)" .
build-windows-amd64:
@CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -o build/bin/windows-amd64/forkdetector.exe -ldflags="github.com/alexeykiselev/waves-fork-detector/version.version=$(VERSION)" .
release: ver build-linux-amd64 build-linux-arm64 build-darwin-amd64 build-darwin-arm64 build-windows-amd64
dist: clean release
@mkdir -p build/dist
@cd ./build/; zip -j ./dist/forkdetector_$(VERSION)_Windows-amd64.zip ./bin/windows-amd64/forkdetector*
@cd ./build/bin/linux-amd64/; tar pzcvf ../../dist/forkdetector_$(VERSION)_Linux-amd64.tar.gz ./forkdetector*
@cd ./build/bin/linux-arm64/; tar pzcvf ../../dist/forkdetector_$(VERSION)_Linux-arm64.tar.gz ./forkdetector*
@cd ./build/bin/darwin-amd64/; tar pzcvf ../../dist/forkdetector_$(VERSION)_macOS-amd64.tar.gz ./forkdetector*
@cd ./build/bin/darwin-arm64/; tar pzcvf ../../dist/forkdetector_$(VERSION)_macOS-arm64.tar.gz ./forkdetector*
mock:
@mockery
docker: ver
@docker build --build-arg VER=${VERSION} . -t ${ORGANISATION}/${PROJECT}:${VERSION}