Makefile

 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
17.PHONY: build
18build:
19	go generate
20	go build -ldflags "$(LDFLAGS)" .
21
22# produce a build debugger friendly
23.PHONY: debug-build
24debug-build:
25	go generate
26	go build -ldflags "$(LDFLAGS)" -gcflags=all="-N -l" .
27
28.PHONY: install
29install:
30	go generate
31	go install -ldflags "$(LDFLAGS)" .
32
33.PHONY: releases
34releases:
35	go generate
36	go run github.com/mitchellh/gox@v1.0.1 -ldflags "$(LDFLAGS)" -output "dist/{{.Dir}}_{{.OS}}_{{.Arch}}"
37
38secure: secure-practices secure-vulnerabilities
39
40.PHONY: secure-practices
41secure-practices:
42	go install github.com/praetorian-inc/gokart
43	gokart scan
44
45.PHONY: secure-vulnerabilities
46secure-vulnerabilities:
47	go install golang.org/x/vuln/cmd/govulncheck@latest
48	govulncheck ./... 
49
50.PHONY: test
51test:
52	go test -v -bench=. ./...
53
54.PHONY: pack-webui
55pack-webui:
56	npm run --prefix webui build
57	go run webui/pack_webui.go
58
59# produce a build that will fetch the web UI from the filesystem instead of from the binary
60.PHONY: debug-webui
61debug-webui:
62	go build -ldflags "$(LDFLAGS)" -tags=debugwebui
63
64.PHONY: clean-local-bugs
65clean-local-bugs:
66	git for-each-ref refs/bugs/ | cut -f 2 | $(XARGS) -n 1 git update-ref -d
67	git for-each-ref refs/remotes/origin/bugs/ | cut -f 2 | $(XARGS) -n 1 git update-ref -d
68	rm -f .git/git-bug/bug-cache
69
70.PHONY: clean-remote-bugs
71clean-remote-bugs:
72	git ls-remote origin "refs/bugs/*" | cut -f 2 | $(XARGS) git push origin -d
73
74.PHONY: clean-local-identities
75clean-local-identities:
76	git for-each-ref refs/identities/ | cut -f 2 | $(XARGS) -n 1 git update-ref -d
77	git for-each-ref refs/remotes/origin/identities/ | cut -f 2 | $(XARGS) -n 1 git update-ref -d
78	rm -f .git/git-bug/identity-cache
79
80.PHONY: clean-local-identities
81clean-remote-identities:
82	git ls-remote origin "refs/identities/*" | cut -f 2 | $(XARGS) git push origin -d