-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
63 lines (50 loc) · 1.59 KB
/
Copy pathMakefile
File metadata and controls
63 lines (50 loc) · 1.59 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
BINARY := ua
PKG := ./cmd/ua
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)
MODULE := github.com/agenticraptor/undo-anything
LDFLAGS := -s -w \
-X '$(MODULE)/internal/buildinfo.Version=$(VERSION)' \
-X '$(MODULE)/internal/buildinfo.Commit=$(COMMIT)' \
-X '$(MODULE)/internal/buildinfo.Date=$(DATE)'
.DEFAULT_GOAL := build
.PHONY: build
build: ## Build the binary into ./bin
@mkdir -p bin
go build -trimpath -ldflags "$(LDFLAGS)" -o bin/$(BINARY) $(PKG)
.PHONY: install
install: ## Install the binary into $GOBIN
go install -trimpath -ldflags "$(LDFLAGS)" $(PKG)
.PHONY: run
run: ## Run against the current folder
go run $(PKG)
.PHONY: test
test: ## Run unit tests
go test ./... -race -count=1
.PHONY: cover
cover: ## Run tests with coverage report
go test ./... -coverprofile=coverage.out
go tool cover -func=coverage.out
.PHONY: vet
vet: ## Run go vet
go vet ./...
.PHONY: lint
lint: ## Run golangci-lint (must be installed)
golangci-lint run
.PHONY: fmt
fmt: ## Format the code
gofmt -s -w .
.PHONY: tidy
tidy: ## Tidy go modules
go mod tidy
.PHONY: snapshot
snapshot: ## Build a local goreleaser snapshot
goreleaser release --snapshot --clean
.PHONY: clean
clean: ## Remove build artifacts
rm -rf bin dist coverage.out coverage.html
.PHONY: help
help: ## Show this help
@grep -hE '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | \
awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-12s\033[0m %s\n", $$1, $$2}'