-
Notifications
You must be signed in to change notification settings - Fork 38
/
Makefile
92 lines (72 loc) · 2.72 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
.PHONY : build test fuzz pack-web build-web serve release-build build-all build-docker release-push push-docker push-latest push-github deploy release-notes check-dirty check-version check-env find-issues
build : test pack-web
mkdir -p release
CGO_ENABLED=0 go build -tags include_web -o release/jd main.go
test :
go test .
go test ./lib
cd v2 ; go test .
fuzz :
go test ./lib -fuzz=FuzzJd -fuzztime=10s
cd v2 ; go test . -fuzz=FuzzJd -fuzztime=10s
pack-web : build-web
go run web/pack/main.go
build-web : check-goroot
cp $$GOROOT/misc/wasm/wasm_exec.js web/assets/
GOOS=js GOARCH=wasm go build -o web/assets/jd.wasm ./web/ui/main.go
serve : pack-web
go run -tags include_web main.go -port 8080
release-build : check-env check-version check-dirty build-all build-docker
@echo
@echo "If everything looks good, run 'make release-push'."
@echo
build-all : test pack-web
mkdir -p release
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -tags include_web -o release/jd-amd64-linux main.go
GOOS=darwin GOARCH=amd64 CGO_ENABLED=0 go build -tags include_web -o release/jd-amd64-darwin main.go
GOOS=windows GOARCH=amd64 CGO_ENABLED=0 go build -tags include_web -o release/jd-amd64-windows.exe main.go
GOOS=linux GOARCH=arm64 CGO_ENABLED=0 go build -tags include_web -o release/jd-arm64-linux main.go
GOOS=darwin GOARCH=arm64 CGO_ENABLED=0 go build -tags include_web -o release/jd-arm64-darwin main.go
GOOS=windows GOARCH=arm64 CGO_ENABLED=0 go build -tags include_web -o release/jd-arm64-windows.exe main.go
build-docker : check-env test
docker build -t josephburnett/jd:v$(JD_VERSION) .
release-push : check-env push-github push-docker push-latest deploy release-notes
@echo
@echo "Upload release/jd-* to Github as release $(JD_VERSION) with release notes above."
@echo
push-docker : check-env
docker push josephburnett/jd:v$(JD_VERSION)
push-latest : check-env
docker tag josephburnett/jd:v$(JD_VERSION) josephburnett/jd:latest
docker push josephburnett/jd:latest
push-github : check-env
git diff --exit-code
git tag v$(JD_VERSION) --force
git push origin v$(JD_VERSION)
deploy : test build-web
gsutil -m cp -r web/assets/* gs://play.jd-tool.io
release-notes : check-env
@echo
@git log --oneline --no-decorate v$(JD_PREVIOUS_VERSION)..v$(JD_VERSION)
check-dirty :
git diff --quiet --exit-code
.ONESHELL:
check-version : check-env
if ! grep -q $(JD_VERSION) main.go; then
@echo "Set 'const version = $(JD_VERSION)' in main.go."
false
fi
check-env :
ifndef JD_VERSION
$(error Set JD_VERSION)
endif
ifndef JD_PREVIOUS_VERSION
$(error Set JD_PREVIOUS_VERSION for release notes)
endif
check-goroot:
ifndef GOROOT
$(error Set GOROOT in order to file wasm_exec.js)
endif
find-issues :
-staticcheck ./...
-goreportcard-cli -v ./...