-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
56 lines (42 loc) · 1.49 KB
/
Copy pathMakefile
File metadata and controls
56 lines (42 loc) · 1.49 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
# Makefile mirrors the justfile. `just` is the primary task runner; this exists
# for contributors who prefer make. Keep the two in sync.
BINARY := mudflaps
PKG := ./...
IMAGE := ghcr.io/intentius/mudflaps
VERSION := $(shell git describe --tags --always --dirty 2>/dev/null || echo dev)
LDFLAGS := -s -w -X main.version=$(VERSION)
.PHONY: build test race lint cover docker run tidy fmt docs-build docs-serve release
build:
go build -ldflags "$(LDFLAGS)" -o $(BINARY) ./cmd/mudflaps
test:
go test $(PKG)
race:
go test -race $(PKG)
lint:
golangci-lint run $(PKG)
cover:
go test -race -coverprofile=coverage.out $(PKG)
go tool cover -func=coverage.out | tail -1
docker:
docker build -t $(IMAGE):$(VERSION) .
run: build
./$(BINARY)
tidy:
go mod tidy
fmt:
gofmt -w .
docs-build:
mkdocs build --strict
docs-serve:
mkdocs serve
# Cut a release: preflight, then tag and push vV. Usage: make release V=0.2.0
# (`just release 0.2.0` is the primary path; see RELEASING.md.)
release:
@test -n "$(V)" || { echo "usage: make release V=X.Y.Z"; exit 1; }
@test -z "$$(git status --porcelain)" || { echo "working tree not clean"; exit 1; }
@test "$$(git rev-parse --abbrev-ref HEAD)" = "main" || { echo "not on main"; exit 1; }
git pull --ff-only origin main
@grep -q "## \[$(V)\]" CHANGELOG.md || { echo "CHANGELOG.md has no '## [$(V)]' section"; exit 1; }
go build ./... && go vet ./... && test -z "$$(gofmt -l .)" && go test ./...
git tag -a "v$(V)" -m "mudflaps v$(V)"
git push origin "v$(V)"