-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathMakefile
More file actions
131 lines (104 loc) · 3.7 KB
/
Makefile
File metadata and controls
131 lines (104 loc) · 3.7 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
MAKEFLAGS += --no-print-directory
.PHONY: all
all: generate
##@ General
# The help target prints out all targets with their descriptions organized
# beneath their categories. The categories are represented by '##@' and the
# target descriptions by '##'. The awk command is responsible for reading the
# entire set of makefiles included in this invocation, looking for lines of the
# file as xyz: ## something, and then pretty-format the target and help. Then,
# if there's a line with ##@ something, that gets pretty-printed as a category.
# More info on the usage of ANSI control characters for terminal formatting:
# https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_parameters
# More info on the awk command:
# http://linuxcommand.org/lc3_adv_awk.php
.PHONY: help
help: ## Display the list of targets and their descriptions
@awk 'BEGIN {FS = ":.*##"; printf "\n\033[1mUsage:\033[0m\n make \033[36m<target>\033[0m\n"} \
/^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-20s\033[0m %s\n", $$1, $$2 } \
/^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } \
/^###/ { printf " \033[90m%s\033[0m\n", substr($$0, 4) }' $(MAKEFILE_LIST)
##@ Tooling
.PHONY: install-devbox
install-devbox: ## Install Devbox
@echo "Installing Devbox..."
@curl -fsSL https://get.jetify.dev | bash
.PHONY: devbox-update
devbox-update: ## Update Devbox
@devbox update
.PHONY: devbox
devbox: ## Run Devbox shell
@devbox shell
##@ Install Dependencies
.PHONY: deps
deps: ## Download go modules
@echo "Downloading go modules..."
go mod download
.PHONY: install
install: ## Install the uuidkey binary
@echo "Installing uuidkey binary..."
go install ./cmd/uuidkey
##@ Development
.PHONY: fmt
fmt: ## Run go fmt
@echo "Running go fmt..."
go fmt ./...
.PHONY: generate
generate: ## Generate and embed go documentation into README.md
@echo "Generating and embedding go documentation into README.md..."
go generate ./...
.PHONY: vet
vet: ## Run go vet
@echo "Running go vet..."
go vet ./...
.PHONY: lint
lint: ## Run golangci-lint
@echo "Running golangci-lint..."
golangci-lint run ./...
##@ Benchmarking, Testing, & Coverage
.PHONY: bench
bench: ## Run Go benchmarks
@echo "Running go benchmarks..."
go test ./... -tags=bench -bench=.
.PHONY: test
test: ## Run Go tests
@echo "Running go tests..."
go test ./... -tags=test
.PHONY: test-cli
test-cli: ## Run CLI-specific tests
@echo "Running CLI tests..."
go test -v ./cmd/uuidkey/...
.PHONY: coverage
coverage: ## Run tests and generate coverage report
@echo "Running tests and generating coverage report..."
go test -race -coverprofile=coverage.txt -covermode=atomic ./...
##@ Build & Release
.PHONY: build
build: ## Build the CLI binary
@echo "Building uuidkey binary..."
go build -o dist/uuidkey ./cmd/uuidkey
.PHONY: build-all
build-all: ## Build binaries for all platforms
@echo "Building binaries for all platforms..."
goreleaser build --snapshot --clean
.PHONY: release
release: ## Create a new release (requires version tag)
@echo "Creating release..."
@if [ -z "$$(git describe --tags --exact-match 2>/dev/null)" ]; then \
echo "Error: No tag found. Please create a tag first using 'make tag VERSION=v1.2.3'"; \
exit 1; \
fi
goreleaser release --clean
.PHONY: release-snapshot
release-snapshot: ## Test release process locally (doesn't publish)
@echo "Testing release process locally..."
goreleaser release --snapshot --clean
.PHONY: tag
tag: ## Create and push a new version tag (usage: make tag VERSION=v1.2.3)
@if [ -z "$(VERSION)" ]; then \
echo "Error: VERSION is required. Usage: make tag VERSION=v1.2.3"; \
exit 1; \
fi
@echo "Creating tag $(VERSION)..."
git tag -a $(VERSION) -m "Release $(VERSION)"
@echo "Tag $(VERSION) created. Push with: git push origin $(VERSION)"