forked from guiyumin/vget
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
37 lines (31 loc) · 1.23 KB
/
Copy pathMakefile
File metadata and controls
37 lines (31 loc) · 1.23 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
.PHONY: build push version patch minor major
BUILD_DIR := ./build
VERSION_FILE := internal/version/version.go
# Get current version from latest git tag (strips 'v' prefix)
CURRENT_VERSION := $(shell git describe --tags --abbrev=0 2>/dev/null | sed 's/^v//' || echo "0.0.0")
build:
go build -o $(BUILD_DIR)/vget ./cmd/vget
push:
git push origin main --tags
# Version bump: make version <patch|minor|major>
version:
@if [ -z "$(filter patch minor major,$(MAKECMDGOALS))" ]; then \
echo "Usage: make version <patch|minor|major>"; \
echo "Current version: $(CURRENT_VERSION)"; \
exit 1; \
fi
patch minor major: version
@TYPE=$@ && \
echo "Current version: $(CURRENT_VERSION)" && \
NEW_VERSION=$$(echo "$(CURRENT_VERSION)" | awk -F. -v type="$$TYPE" '{ \
if (type == "major") { print $$1+1".0.0" } \
else if (type == "minor") { print $$1"."$$2+1".0" } \
else { print $$1"."$$2"."$$3+1 } \
}') && \
echo "New version: $$NEW_VERSION" && \
sed -i '' 's/Version = ".*"/Version = "'$$NEW_VERSION'"/' $(VERSION_FILE) && \
git add $(VERSION_FILE) && \
git commit -m "chore: bump version to v$$NEW_VERSION" && \
git tag "v$$NEW_VERSION" && \
echo "Created tag v$$NEW_VERSION" && \
echo "Run 'make push' to push changes and trigger release"