Skip to content

Commit ac31ebd

Browse files
committed
add Makefile
1 parent 0b93018 commit ac31ebd

File tree

1 file changed

+66
-0
lines changed

1 file changed

+66
-0
lines changed

Makefile

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# Detect platform for sed compatibility
2+
SED := $(shell if [ "$(shell uname)" = "Darwin" ]; then echo gsed; else echo sed; fi)
3+
4+
# Find the latest tag (default to 0.0.0 if none found)
5+
LATEST_TAG := $(shell git tag --list 'v*' --sort=-v:refname | head -n 1)
6+
VERSION := $(shell echo $(LATEST_TAG) | sed 's/^v//' || echo "0.0.0")
7+
8+
.PHONY: test cover clean update patch minor major tag
9+
10+
##@ General
11+
12+
.PHONY: help
13+
help: ## Display this help.
14+
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
15+
16+
##@ Development
17+
18+
.PHONY: download
19+
download: ## Download go packages
20+
go mod download
21+
22+
.PHONY: update-packages
23+
update-packages: ## Update all Go packages to their latest versions
24+
go get -u ./...
25+
go mod tidy
26+
27+
.PHONY: fmt
28+
fmt: ## Run go fmt against code.
29+
go fmt .
30+
31+
.PHONY: vet
32+
vet: ## Run go vet against code.
33+
go vet .
34+
35+
.PHONY: test
36+
test: ## Run all unit tests
37+
go test . -count=1
38+
39+
.PHONY: cover
40+
cover: ## Generate and display test coverage
41+
go test . -count=1 -coverprofile=coverage.out
42+
go tool cover -html=coverage.out
43+
44+
.PHONY: clean
45+
clean: ## Clean up generated files
46+
rm -f coverage.out coverage.html
47+
48+
##@ Versioning
49+
50+
patch: ## Create a new patch release (x.y.Z+1)
51+
@NEW_VERSION=$$(echo "$(VERSION)" | awk -F. '{printf "%d.%d.%d", $$1, $$2, $$3+1}') && \
52+
git tag "v$${NEW_VERSION}" && \
53+
echo "Tagged v$${NEW_VERSION}"
54+
55+
minor: ## Create a new minor release (x.Y+1.0)
56+
@NEW_VERSION=$$(echo "$(VERSION)" | awk -F. '{printf "%d.%d.0", $$1, $$2+1}') && \
57+
git tag "v$${NEW_VERSION}" && \
58+
echo "Tagged v$${NEW_VERSION}"
59+
60+
major: ## Create a new major release (X+1.0.0)
61+
@NEW_VERSION=$$(echo "$(VERSION)" | awk -F. '{printf "%d.0.0", $$1+1}') && \
62+
git tag "v$${NEW_VERSION}" && \
63+
echo "Tagged v$${NEW_VERSION}"
64+
65+
tag: ## Show latest tag
66+
@echo "Latest version: $(LATEST_TAG)"

0 commit comments

Comments
 (0)