Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
80 lines (64 loc) · 2.22 KB
/
Copy pathMakefile
File metadata and controls
80 lines (64 loc) · 2.22 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
.PHONY: build test clean install lint fmt vet
# Build variables
BINARY_NAME=auto-git-config
VERSION?=$(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
COMMIT?=$(shell git rev-parse --short HEAD 2>/dev/null || echo "none")
BUILD_DATE?=$(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
LDFLAGS=-ldflags "-X main.version=$(VERSION) -X main.commit=$(COMMIT) -X main.buildDate=$(BUILD_DATE)"
# Default target
all: build
# Build the binary
build:
go build $(LDFLAGS) -o $(BINARY_NAME) ./cmd/auto-git-config
# Build for all platforms
build-all:
GOOS=darwin GOARCH=amd64 go build $(LDFLAGS) -o dist/$(BINARY_NAME)-darwin-amd64 ./cmd/auto-git-config
GOOS=darwin GOARCH=arm64 go build $(LDFLAGS) -o dist/$(BINARY_NAME)-darwin-arm64 ./cmd/auto-git-config
GOOS=linux GOARCH=amd64 go build $(LDFLAGS) -o dist/$(BINARY_NAME)-linux-amd64 ./cmd/auto-git-config
GOOS=linux GOARCH=arm64 go build $(LDFLAGS) -o dist/$(BINARY_NAME)-linux-arm64 ./cmd/auto-git-config
GOOS=windows GOARCH=amd64 go build $(LDFLAGS) -o dist/$(BINARY_NAME)-windows-amd64.exe ./cmd/auto-git-config
# Run tests
test:
go test -v ./...
# Run tests with coverage
test-coverage:
go test -v -coverprofile=coverage.out ./...
go tool cover -html=coverage.out -o coverage.html
# Clean build artifacts
clean:
rm -f $(BINARY_NAME)
rm -rf dist/
rm -f coverage.out coverage.html
# Install to GOPATH/bin
install:
go install $(LDFLAGS) ./cmd/auto-git-config
# Run linter (requires golangci-lint)
lint:
golangci-lint run
# Format code
fmt:
go fmt ./...
# Run go vet
vet:
go vet ./...
# Run all checks
check: fmt vet test
# Development: build and run explain
dev-explain: build
./$(BINARY_NAME) explain
# Development: initialize config
dev-init: build
./$(BINARY_NAME) init --force
# Show help
help:
@echo "Available targets:"
@echo " build - Build the binary"
@echo " build-all - Build for all platforms"
@echo " test - Run tests"
@echo " test-coverage- Run tests with coverage report"
@echo " clean - Remove build artifacts"
@echo " install - Install to GOPATH/bin"
@echo " lint - Run golangci-lint"
@echo " fmt - Format code"
@echo " vet - Run go vet"
@echo " check - Run all checks (fmt, vet, test)"