1all: build
2
3GIT_COMMIT:=$(shell git rev-list -1 HEAD)
4GIT_LAST_TAG:=$(shell git describe --abbrev=0 --tags)
5GIT_EXACT_TAG:=$(shell git name-rev --name-only --tags HEAD)
6UNAME_S := $(shell uname -s)
7XARGS:=xargs -r
8ifeq ($(UNAME_S),Darwin)
9 XARGS:=xargs
10endif
11
12COMMANDS_PATH:=github.com/MichaelMure/git-bug/commands
13LDFLAGS:=-X ${COMMANDS_PATH}.GitCommit=${GIT_COMMIT} \
14 -X ${COMMANDS_PATH}.GitLastTag=${GIT_LAST_TAG} \
15 -X ${COMMANDS_PATH}.GitExactTag=${GIT_EXACT_TAG}
16
17build:
18 go generate
19 go build -ldflags "$(LDFLAGS)" .
20
21# produce a build debugger friendly
22debug-build:
23 go generate
24 go build -ldflags "$(LDFLAGS)" -gcflags=all="-N -l" .
25
26install:
27 go generate
28 go install -ldflags "$(LDFLAGS)" .
29
30releases:
31 go generate
32 gox -ldflags "$(LDFLAGS)" -output "dist/{{.Dir}}_{{.OS}}_{{.Arch}}"
33
34secure: secure-practices secure-vulnerabilities
35
36secure-practices:
37 go install github.com/praetorian-inc/gokart
38 gokart scan
39
40secure-vulnerabilities:
41 go install golang.org/x/vuln/cmd/govulncheck@latest
42 govulncheck ./...
43
44legal: build
45 go install github.com/uw-labs/lichen@latest
46 lichen --config=.lichen.yaml ./git-bug
47
48test:
49 go test -v -bench=. ./...
50
51pack-webui:
52 npm run --prefix webui build
53 go run webui/pack_webui.go
54
55# produce a build that will fetch the web UI from the filesystem instead of from the binary
56debug-webui:
57 go build -ldflags "$(LDFLAGS)" -tags=debugwebui
58
59clean-local-bugs:
60 git for-each-ref refs/bugs/ | cut -f 2 | $(XARGS) -n 1 git update-ref -d
61 git for-each-ref refs/remotes/origin/bugs/ | cut -f 2 | $(XARGS) -n 1 git update-ref -d
62 rm -f .git/git-bug/bug-cache
63
64clean-remote-bugs:
65 git ls-remote origin "refs/bugs/*" | cut -f 2 | $(XARGS) git push origin -d
66
67clean-local-identities:
68 git for-each-ref refs/identities/ | cut -f 2 | $(XARGS) -n 1 git update-ref -d
69 git for-each-ref refs/remotes/origin/identities/ | cut -f 2 | $(XARGS) -n 1 git update-ref -d
70 rm -f .git/git-bug/identity-cache
71
72clean-remote-identities:
73 git ls-remote origin "refs/identities/*" | cut -f 2 | $(XARGS) git push origin -d
74
75.PHONY: build install releases test pack-webui debug-webui clean-local-bugs clean-remote-bugs
76.PHONY: secure secure-vulnerabilities secure-practices