-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
79 lines (58 loc) · 2.08 KB
/
Copy pathMakefile
File metadata and controls
79 lines (58 loc) · 2.08 KB
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
VERSION ?= 0.0.1-dev
COMMIT ?= $(shell git rev-parse --short HEAD 2>/dev/null || echo unknown)
LDFLAGS := -X github.com/marstack-labs/marstack-access/internal/version.Version=$(VERSION) \
-X github.com/marstack-labs/marstack-access/internal/version.Commit=$(COMMIT)
GOBIN ?= $(shell go env GOPATH)/bin
PREFIX ?= /usr/local
PLATFORMS := linux/amd64 linux/arm64 darwin/amd64 darwin/arm64
SHA256 := $(shell command -v sha256sum >/dev/null 2>&1 && echo "sha256sum" || echo "shasum -a 256")
.PHONY: build install uninstall site dist test vet fmt staticcheck vuln gosec secrets security check tools hooks run clean
build:
go build -ldflags "$(LDFLAGS)" -o bin/marac ./cmd/marac
install:
install -d $(DESTDIR)$(PREFIX)/bin
install -m 0755 bin/marac $(DESTDIR)$(PREFIX)/bin/marac
uninstall:
rm -f $(DESTDIR)$(PREFIX)/bin/marac
site:
cp internal/console/assets/meridian.css site/meridian.css
dist:
rm -rf dist && mkdir -p dist
@for platform in $(PLATFORMS); do \
os=$${platform%/*}; arch=$${platform#*/}; \
echo "building marac $(VERSION) for $$os/$$arch"; \
CGO_ENABLED=0 GOOS=$$os GOARCH=$$arch \
go build -trimpath -ldflags "$(LDFLAGS)" -o dist/marac ./cmd/marac || exit 1; \
tar -czf dist/marac_$(VERSION)_$${os}_$${arch}.tar.gz -C dist marac \
-C .. LICENSE README.md || exit 1; \
rm dist/marac; \
done
cd dist && $(SHA256) *.tar.gz > SHA256SUMS
test:
go test -race ./...
vet:
go vet ./...
fmt:
gofmt -l -w .
staticcheck:
$(GOBIN)/staticcheck ./...
vuln:
$(GOBIN)/govulncheck ./...
gosec:
$(GOBIN)/gosec -quiet -severity medium -confidence medium ./...
secrets:
$(GOBIN)/gitleaks detect --redact --no-banner --exit-code 1
security: vuln gosec secrets
check: vet test staticcheck security
tools:
go install honnef.co/go/tools/cmd/staticcheck@latest
go install golang.org/x/vuln/cmd/govulncheck@latest
go install github.com/securego/gosec/v2/cmd/gosec@latest
go install github.com/zricethezav/gitleaks/v8@latest
hooks:
git config core.hooksPath .githooks
chmod +x .githooks/pre-commit
run: build
./bin/marac server
clean:
rm -rf bin dist data coverage.out