-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathMakefile
More file actions
39 lines (33 loc) · 1.54 KB
/
Makefile
File metadata and controls
39 lines (33 loc) · 1.54 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
.PHONY: release-patch release-minor release-major release check-clean
# Get current version from latest tag, default to 0.0.0
CURRENT_VERSION := $(shell git describe --tags --abbrev=0 2>/dev/null | sed 's/^v//' || echo "0.0.0")
MAJOR := $(shell echo $(CURRENT_VERSION) | cut -d. -f1)
MINOR := $(shell echo $(CURRENT_VERSION) | cut -d. -f2)
PATCH := $(shell echo $(CURRENT_VERSION) | cut -d. -f3)
check-clean: ## Verify git is clean and synced with remote
@if [ -n "$$(git status --porcelain)" ]; then \
echo "Error: Working directory not clean. Commit or stash changes first."; \
exit 1; \
fi
@git fetch origin
@if [ "$$(git rev-parse HEAD)" != "$$(git rev-parse @{u})" ]; then \
echo "Error: Local branch not synced with remote. Push or pull first."; \
exit 1; \
fi
@echo "Git state OK: clean and synced"
release-patch: check-clean ## Release patch version (0.1.0 -> 0.1.1)
@NEW_VERSION="$(MAJOR).$(MINOR).$$(($(PATCH)+1))" && \
echo "Releasing v$$NEW_VERSION" && \
git tag -a "v$$NEW_VERSION" -m "Release v$$NEW_VERSION" && \
git push --tags
release-minor: check-clean ## Release minor version (0.1.0 -> 0.2.0)
@NEW_VERSION="$(MAJOR).$$(($(MINOR)+1)).0" && \
echo "Releasing v$$NEW_VERSION" && \
git tag -a "v$$NEW_VERSION" -m "Release v$$NEW_VERSION" && \
git push --tags
release-major: check-clean ## Release major version (0.1.0 -> 1.0.0)
@NEW_VERSION="$$(($(MAJOR)+1)).0.0" && \
echo "Releasing v$$NEW_VERSION" && \
git tag -a "v$$NEW_VERSION" -m "Release v$$NEW_VERSION" && \
git push --tags
release: release-patch ## Default: patch release