-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
84 lines (70 loc) · 2.21 KB
/
Copy pathMakefile
File metadata and controls
84 lines (70 loc) · 2.21 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
80
81
82
83
84
# Makefile for urlhs
# Version information
VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
COMMIT ?= $(shell git rev-parse --short HEAD 2>/dev/null || echo "unknown")
BUILD_DATE ?= $(shell date -u +%Y-%m-%dT%H:%M:%SZ)
# Build flags
LDFLAGS := -X github.com/andpalmier/urlhs/cmd.Version=$(VERSION) \
-X github.com/andpalmier/urlhs/cmd.Commit=$(COMMIT) \
-X github.com/andpalmier/urlhs/cmd.BuildDate=$(BUILD_DATE)
# Binary name
BINARY := urlhs
.PHONY: all
all: build
.PHONY: build
build:
@echo "Building $(BINARY) $(VERSION)..."
go build -ldflags "$(LDFLAGS)" -o $(BINARY) main.go
@echo "Build complete: ./$(BINARY)"
.PHONY: build-release
build-release:
@echo "Building release binary $(BINARY) $(VERSION)..."
go build -ldflags "-s -w $(LDFLAGS)" -o $(BINARY) main.go
@echo "Release build complete: ./$(BINARY)"
.PHONY: install
install:
@echo "Installing $(BINARY) $(VERSION)..."
go install -ldflags "$(LDFLAGS)"
@echo "Installed to $(shell go env GOPATH)/bin/$(BINARY)"
.PHONY: test
test:
@echo "Running tests..."
go test -v ./...
.PHONY: test-coverage
test-coverage:
@echo "Running tests with coverage..."
go test -v -coverprofile=coverage.out ./...
go tool cover -html=coverage.out -o coverage.html
@echo "Coverage report: coverage.html"
.PHONY: lint
lint:
@echo "Running linters..."
go vet ./...
go fmt ./...
.PHONY: clean
clean:
@echo "Cleaning..."
rm -f $(BINARY)
rm -f coverage.out coverage.html
@echo "Clean complete"
.PHONY: run
run: build
./$(BINARY)
.PHONY: version
version:
@echo "Version: $(VERSION)"
@echo "Commit: $(COMMIT)"
@echo "Built: $(BUILD_DATE)"
.PHONY: help
help:
@echo "Available targets:"
@echo " make build - Build binary with version info"
@echo " make build-release - Build optimized release binary"
@echo " make install - Install to GOPATH/bin"
@echo " make test - Run tests"
@echo " make test-coverage - Run tests with coverage report"
@echo " make lint - Run linters"
@echo " make clean - Remove built binaries"
@echo " make run - Build and run"
@echo " make version - Show version information"
@echo " make help - Show this help message"