-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
74 lines (58 loc) · 1.49 KB
/
Makefile
File metadata and controls
74 lines (58 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# Dotfiles Makefile
.PHONY: build clean test install dev release-test help
# Build variables
BINARY_NAME=dotfiles
VERSION=$(shell git describe --tags --always --dirty)
COMMIT=$(shell git rev-parse HEAD)
DATE=$(shell date -u '+%Y-%m-%d_%H:%M:%S')
# Go build flags
LDFLAGS=-ldflags "-s -w -X main.version=$(VERSION) -X main.commit=$(COMMIT) -X main.date=$(DATE)"
# Default target
all: build
## build: Build the binary
build:
@echo "Building $(BINARY_NAME)..."
go build $(LDFLAGS) -o $(BINARY_NAME) .
## clean: Clean build artifacts
clean:
@echo "Cleaning..."
rm -f $(BINARY_NAME)
rm -rf dist/
## test: Run tests
test:
@echo "Running tests..."
go test -v ./...
## install: Install the binary to $GOPATH/bin
install:
@echo "Installing $(BINARY_NAME)..."
go install $(LDFLAGS) .
## dev: Build and run in development mode
dev: build
./$(BINARY_NAME)
## release-test: Test the release process
release-test:
@echo "Testing release process..."
goreleaser release --snapshot --clean
## deps: Install dependencies
deps:
@echo "Installing dependencies..."
go mod download
go mod tidy
## lint: Run linters
lint:
@echo "Running linters..."
golangci-lint run
## fmt: Format code
fmt:
@echo "Formatting code..."
go fmt ./...
## mod-tidy: Tidy go modules
mod-tidy:
@echo "Tidying go modules..."
go mod tidy
## check: Run all checks (test, lint, fmt)
check: test lint fmt
## help: Show this help
help:
@echo "Available targets:"
@sed -n 's/^##//p' $(MAKEFILE_LIST) | column -t -s ':' | sed -e 's/^/ /'