Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
55 lines (41 loc) · 1.56 KB
/
Copy pathMakefile
File metadata and controls
55 lines (41 loc) · 1.56 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
BINARY := waitfor
PKG := github.com/0xProgress/waitfor
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 $(PKG)/internal/version.Version=$(VERSION) \
-X $(PKG)/internal/version.Commit=$(COMMIT) \
-X $(PKG)/internal/version.Date=$(DATE)
GOBIN ?= $(shell go env GOPATH)/bin
BIN_DIR := bin
.PHONY: all build install test race vet fmt lint check clean release help
all: build
build: ## build the binary into ./bin
@mkdir -p $(BIN_DIR)
go build -trimpath -ldflags "$(LDFLAGS)" -o $(BIN_DIR)/$(BINARY) .
install: ## install into $GOBIN
go install -trimpath -ldflags "$(LDFLAGS)" .
test: ## run unit tests
go test ./... -count=1
race: ## run tests with the race detector
go test -race ./... -count=1
vet: ## go vet
go vet ./...
fmt: ## gofmt all Go files
gofmt -s -w .
lint: vet ## vet + check for unformatted files
@out=$$(gofmt -l .); \
if [ -n "$$out" ]; then \
echo "unformatted files:"; echo "$$out"; exit 1; \
fi
check: lint race ## run all checks (lint + race tests) — same as CI
@echo "✓ All checks passed"
clean: ## remove build artifacts
rm -rf $(BIN_DIR) dist/
release: ## snapshot release (writes to ./dist)
goreleaser release --snapshot --clean
help: ## show this help
@awk 'BEGIN {FS = ":.*?## "} \
/^[a-zA-Z_-]+:.*?## / {printf " \033[36m%-12s\033[0m %s\n", $$1, $$2}' \
$(MAKEFILE_LIST)