1all: build
2
3GIT_COMMIT:=$(shell git rev-list -1 HEAD)
4GIT_LAST_TAG:=$(shell git describe --abbrev=0 --tags 2>/dev/null || true)
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
12SYSTEM=$(shell nix eval --impure --expr 'builtins.currentSystem' --raw 2>/dev/null || echo '')
13
14COMMANDS_PATH:=github.com/git-bug/git-bug/commands
15LDFLAGS:=-X ${COMMANDS_PATH}.GitCommit="${GIT_COMMIT}" \
16 -X ${COMMANDS_PATH}.GitLastTag="${GIT_LAST_TAG}" \
17 -X ${COMMANDS_PATH}.GitExactTag="${GIT_EXACT_TAG}"
18
19.PHONY: list-checks
20list-checks:
21 @if test -z "$(SYSTEM)"; then echo "unable to detect system. is nix installed?" && exit 1; fi
22 @printf "Available checks for $(SYSTEM) (run all with \`nix flake check\`):\n"
23 @nix flake show --json 2>/dev/null |\
24 dasel -r json -w plain '.checks.x86_64-linux.keys().all()' |\
25 xargs -I NAME printf '\t%-20s %s\n' "NAME" "nix build .#checks.linux.NAME"
26
27.PHONY: build
28build:
29 go generate
30 go build -ldflags "$(LDFLAGS)" .
31
32# produce a debugger-friendly build
33.PHONY: build/debug
34build/debug:
35 go generate
36 go build -ldflags "$(LDFLAGS)" -gcflags=all="-N -l" .
37
38.PHONY: install
39install:
40 go generate
41 go install -ldflags "$(LDFLAGS)" .
42
43.PHONY: releases
44releases:
45 go generate
46 go run github.com/mitchellh/gox@v1.0.1 -ldflags "$(LDFLAGS)" -osarch '!darwin/386' -output "dist/{{.Dir}}_{{.OS}}_{{.Arch}}"
47
48secure: secure-practices secure-vulnerabilities
49
50.PHONY: secure-practices
51secure-practices:
52 go run github.com/praetorian-inc/gokart scan
53
54.PHONY: secure-vulnerabilities
55secure-vulnerabilities:
56 go run golang.org/x/vuln/cmd/govulncheck ./...
57
58.PHONY: test
59test:
60 go test -v -bench=. ./...
61
62.PHONY: pack-webui
63pack-webui:
64 npm run --prefix webui build
65 go run webui/pack_webui.go
66
67# produce a build that will fetch the web UI from the filesystem instead of from the binary
68.PHONY: debug-webui
69debug-webui:
70 go build -ldflags "$(LDFLAGS)" -tags=debugwebui
71
72.PHONY: clean-local-bugs
73clean-local-bugs:
74 git for-each-ref refs/bugs/ | cut -f 2 | $(XARGS) -n 1 git update-ref -d
75 git for-each-ref refs/remotes/origin/bugs/ | cut -f 2 | $(XARGS) -n 1 git update-ref -d
76 rm -f .git/git-bug/bug-cache
77
78.PHONY: clean-remote-bugs
79clean-remote-bugs:
80 git ls-remote origin "refs/bugs/*" | cut -f 2 | $(XARGS) git push origin -d
81
82.PHONY: clean-local-identities
83clean-local-identities:
84 git for-each-ref refs/identities/ | cut -f 2 | $(XARGS) -n 1 git update-ref -d
85 git for-each-ref refs/remotes/origin/identities/ | cut -f 2 | $(XARGS) -n 1 git update-ref -d
86 rm -f .git/git-bug/identity-cache
87
88.PHONY: clean-local-identities
89clean-remote-identities:
90 git ls-remote origin "refs/identities/*" | cut -f 2 | $(XARGS) git push origin -d