-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMakefile
More file actions
58 lines (45 loc) · 1.58 KB
/
Makefile
File metadata and controls
58 lines (45 loc) · 1.58 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
GO ?= go
BINARY := agentcheck
MAIN := ./cmd/agentcheck
VERSION := $(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
COMMIT := $(shell git rev-parse --short HEAD 2>/dev/null || echo "none")
DATE := $(shell date -u +%Y-%m-%dT%H:%M:%SZ)
LDFLAGS := -s -w \
-X main.version=$(VERSION) \
-X main.commit=$(COMMIT) \
-X main.date=$(DATE)
.PHONY: help build test lint lint-fix tidy clean snapshot release-dry-run hooks
help:
@echo "Available targets:"
@echo " build compile the binary to ./$(BINARY)"
@echo " test run all tests with race detector"
@echo " lint run golangci-lint"
@echo " lint-fix run golangci-lint with auto-fix"
@echo " tidy tidy and verify go.mod / go.sum"
@echo " clean remove built binary and dist/"
@echo " hooks install pre-commit hooks (run once after clone)"
@echo " snapshot build release archives locally (requires goreleaser)"
@echo " release-dry-run dry-run the full release (no publish)"
build:
$(GO) build -ldflags "$(LDFLAGS)" -o $(BINARY) $(MAIN)
test:
$(GO) test -race -count=1 ./...
lint:
golangci-lint run ./...
lint-fix:
golangci-lint run --fix ./...
tidy:
$(GO) mod tidy
$(GO) mod verify
clean:
rm -f $(BINARY)
rm -rf dist/
hooks:
pre-commit install
# Build release archives locally without publishing.
# Requires: goreleaser (brew install goreleaser)
snapshot:
goreleaser release --snapshot --clean
# Full dry-run (validates .goreleaser.yml, builds, skips publish).
release-dry-run:
goreleaser release --skip=publish --clean