Skip to content

Commit 2030ee2

Browse files
committed
Add release management targets to Makefile [skip ci]
Added semantic versioning targets similar to rootly-go: - make version: Show current version and recent tags - make bump-patch: Bump patch version (0.0.1 -> 0.0.2) - make bump-minor: Bump minor version (0.0.1 -> 0.1.0) - make bump-major: Bump major version (0.0.1 -> 1.0.0) - make push-tag: Push latest tag to remote - make release-patch: Bump patch and push tag - make release-minor: Bump minor and push tag - make release-major: Bump major and push tag Version bumping updates both pom.xml and build.gradle, creates a git commit, and creates a git tag. Use release-* targets for one-step version bump and tag push.
1 parent ffb643f commit 2030ee2

1 file changed

Lines changed: 74 additions & 1 deletion

File tree

Makefile

Lines changed: 74 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.PHONY: build build-docker build-local upgrade-deps
1+
.PHONY: build build-docker build-local upgrade-deps version bump-patch bump-minor bump-major push-tag release-patch release-minor release-major
22

33
# Default target uses Docker (recommended - no Java installation required)
44
build: build-docker
@@ -38,3 +38,76 @@ upgrade-deps:
3838
mvn versions:use-latest-versions -DallowMajorUpdates=false -DprocessDependencyManagement=false
3939
@echo "✓ Dependencies upgraded in pom.xml"
4040
@echo "⚠️ Remember to manually sync versions to build.gradle"
41+
42+
# Version management
43+
LATEST_TAG := $(shell git tag -l 'v*' --sort=-v:refname | head -1)
44+
LATEST_TAG_OR_DEFAULT := $(if $(LATEST_TAG),$(LATEST_TAG),v0.0.0)
45+
CURRENT_VERSION := $(shell grep '<version>' pom.xml | head -1 | sed 's/.*<version>\(.*\)<\/version>.*/\1/')
46+
47+
version: ## Show current version and recent tags
48+
@echo "Current version (pom.xml): $(CURRENT_VERSION)"
49+
@echo "Latest git tag: $(LATEST_TAG_OR_DEFAULT)"
50+
@echo ""
51+
@echo "Recent tags:"
52+
@git tag -l 'v*' --sort=-v:refname | head -5
53+
54+
bump-patch: ## Bump patch version (0.0.1 -> 0.0.2)
55+
@if [ -z "$(LATEST_TAG)" ]; then \
56+
NEW_VERSION="0.0.1"; \
57+
NEW_TAG="v0.0.1"; \
58+
else \
59+
NEW_VERSION=$$(echo $(LATEST_TAG) | sed 's/v//' | awk -F. '{print $$1"."$$2"."$$3+1}'); \
60+
NEW_TAG="v$$NEW_VERSION"; \
61+
fi; \
62+
echo "Bumping $(LATEST_TAG_OR_DEFAULT) -> $$NEW_TAG"; \
63+
sed -i '' "s|<version>$(CURRENT_VERSION)</version>|<version>$$NEW_VERSION</version>|" pom.xml; \
64+
sed -i '' "s|version = '$(CURRENT_VERSION)'|version = '$$NEW_VERSION'|" build.gradle; \
65+
git add pom.xml build.gradle; \
66+
git commit -m "Bump version to $$NEW_VERSION [skip ci]"; \
67+
git tag -a $$NEW_TAG -m "Release $$NEW_TAG"; \
68+
echo "✓ Created tag $$NEW_TAG (use 'make push-tag' to push)"
69+
70+
bump-minor: ## Bump minor version (0.0.1 -> 0.1.0)
71+
@if [ -z "$(LATEST_TAG)" ]; then \
72+
NEW_VERSION="0.1.0"; \
73+
NEW_TAG="v0.1.0"; \
74+
else \
75+
NEW_VERSION=$$(echo $(LATEST_TAG) | sed 's/v//' | awk -F. '{print $$1"."$$2+1".0"}'); \
76+
NEW_TAG="v$$NEW_VERSION"; \
77+
fi; \
78+
echo "Bumping $(LATEST_TAG_OR_DEFAULT) -> $$NEW_TAG"; \
79+
sed -i '' "s|<version>$(CURRENT_VERSION)</version>|<version>$$NEW_VERSION</version>|" pom.xml; \
80+
sed -i '' "s|version = '$(CURRENT_VERSION)'|version = '$$NEW_VERSION'|" build.gradle; \
81+
git add pom.xml build.gradle; \
82+
git commit -m "Bump version to $$NEW_VERSION [skip ci]"; \
83+
git tag -a $$NEW_TAG -m "Release $$NEW_TAG"; \
84+
echo "✓ Created tag $$NEW_TAG (use 'make push-tag' to push)"
85+
86+
bump-major: ## Bump major version (0.0.1 -> 1.0.0)
87+
@if [ -z "$(LATEST_TAG)" ]; then \
88+
NEW_VERSION="1.0.0"; \
89+
NEW_TAG="v1.0.0"; \
90+
else \
91+
NEW_VERSION=$$(echo $(LATEST_TAG) | sed 's/v//' | awk -F. '{print $$1+1".0.0"}'); \
92+
NEW_TAG="v$$NEW_VERSION"; \
93+
fi; \
94+
echo "Bumping $(LATEST_TAG_OR_DEFAULT) -> $$NEW_TAG"; \
95+
sed -i '' "s|<version>$(CURRENT_VERSION)</version>|<version>$$NEW_VERSION</version>|" pom.xml; \
96+
sed -i '' "s|version = '$(CURRENT_VERSION)'|version = '$$NEW_VERSION'|" build.gradle; \
97+
git add pom.xml build.gradle; \
98+
git commit -m "Bump version to $$NEW_VERSION [skip ci]"; \
99+
git tag -a $$NEW_TAG -m "Release $$NEW_TAG"; \
100+
echo "✓ Created tag $$NEW_TAG (use 'make push-tag' to push)"
101+
102+
push-tag: ## Push the latest tag to remote
103+
@TAG=$$(git tag -l 'v*' --sort=-v:refname | head -1); \
104+
if [ -z "$$TAG" ]; then \
105+
echo "No tags found"; \
106+
exit 1; \
107+
fi; \
108+
echo "Pushing $$TAG to origin..."; \
109+
git push origin $$TAG
110+
111+
release-patch: bump-patch push-tag ## Bump patch version and push tag
112+
release-minor: bump-minor push-tag ## Bump minor version and push tag
113+
release-major: bump-major push-tag ## Bump major version and push tag

0 commit comments

Comments
 (0)