-
Notifications
You must be signed in to change notification settings - Fork 10
/
Makefile
96 lines (67 loc) · 2.95 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
VERSION = $(shell git describe --tags --match="[0-9]\.[0-9]\.[0-9]" 2> /dev/null || echo 0.0.0)
APPID = com.github.fabiodcorreia.catch-my-file
ICON = assets/icons/icon-512.png
NAME = CatchMyFile
TARGET = pkg/**/*.go
format:
@gofmt -s -w $(TARGET)
review: format
@echo "============= Spell Check ============= "
@misspell .
@echo "============= Ineffectual Assignments Check ============= "
@ineffassign ./...
@echo "============= Duplication Check ============= "
find ./pkg -not -name '*_test.go' -name '*.go' | dupl -t 30 -files
@echo "============= Repeated Strings Check ============= "
@goconst $(TARGET)
@echo "============= Security Check ============= "
@gosec ./...
@echo "============= Vet Check ============= "
@go vet --all .
@echo "============= Preallocation Check ============= "
@prealloc -forloops -set_exit_status -simple -rangeloops ./...
@echo "============= Shadow Variables Check ============= "
@shadow -strict ./...
@echo "============= Cyclomatic Complexity Check ============= "
@gocyclo -total -ignore "_test" -over 8 -avg $(TARGET)
test:
@go test -cover ./pkg/...
cover:
@go test -coverprofile=coverage.out ./pkg/...
@go tool cover -func=coverage.out
cover-html:
@go test -coverprofile=coverage.out ./pkg/...
@go tool cover -html=coverage.out
bench:
go test -benchtime=1s -count=5 -benchmem -bench . ./pkg/...
pre-build: review test
go mod tidy
build: pre-build
go build -tags release -ldflags="-s -w" -o $(NAME)
darwin: pre-build
fyne-cross darwin -arch amd64,arm64 -app-id $(APPID) -icon $(ICON) -app-version $(VERSION) -output $(NAME)
linux: pre-build
fyne-cross linux -arch amd64,arm64 -app-id $(APPID) -icon $(ICON) -app-version $(VERSION) -output catch-my-file
windows: pre-build
fyne-cross windows -arch amd64 -app-id $(APPID) -icon $(ICON) -app-version $(VERSION) -output "$(NAME).exe"
build-all: pre-build darwin linux windows
bundle-linux: linux
mkdir -p ./dist
mv fyne-cross/dist/linux-amd64/catch-my-file.tar.gz dist/$(NAME)-$(VERSION)-linux-amd64.tar.gz
mv fyne-cross/dist/linux-arm64/catch-my-file.tar.gz dist/$(NAME)-$(VERSION)-linux-arm64.tar.gz
bundle-darwin: darwin
mkdir -p ./dist
(cd fyne-cross/dist/darwin-amd64/ && zip -r $(NAME)-darwin-amd64.zip $(NAME).app/)
mv fyne-cross/dist/darwin-amd64/$(NAME)-darwin-amd64.zip dist/$(NAME)-$(VERSION)-darwin-amd64.zip
#(cd fyne-cross/dist/darwin-arm64/ && zip -r $(NAME)-darwin-arm64.zip $(NAME).app/)
#mv fyne-cross/dist/darwin-arm64/$(NAME)-darwin-arm64.zip dist/$(NAME)-$(VERSION)-darwin-arm64.zip
bundle-windows: windows
mkdir -p ./dist
mv fyne-cross/dist/windows-amd64/$(NAME).exe.zip dist/$(NAME)-$(VERSION)-windows-amd64.zip
release: bundle-linux bundle-darwin bundle-windows
tools:
go get -u github.com/jgautheron/goconst/cmd/goconst
go get -u github.com/mdempsky/unconvert
go get -u github.com/securego/gosec/v2/cmd/gosec
go get -u github.com/alexkohler/prealloc
go install golang.org/x/tools/go/analysis/passes/shadow/cmd/shadow@latest