19 lines
725 B
Makefile
19 lines
725 B
Makefile
# Variables
|
|
REPO_REMOTE := origin
|
|
|
|
# Helper function to get the latest tag and increment the version
|
|
define next_version
|
|
latest_tag=$$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0"); \
|
|
major=$$(echo $$latest_tag | sed -E 's/^v([0-9]+)\.[0-9]+\.[0-9]+/\1/'); \
|
|
minor=$$(echo $$latest_tag | sed -E 's/^v[0-9]+\.([0-9]+)\.[0-9]+/\1/'); \
|
|
patch=$$(echo $$latest_tag | sed -E 's/^v[0-9]+\.[0-9]+\.([0-9]+)/\1/'); \
|
|
next_patch=$$(($$patch + 1)); \
|
|
echo "v$$major.$$minor.$$next_patch"
|
|
endef
|
|
|
|
# Target to tag and push the next version
|
|
release:
|
|
@next_version=$$($(next_version)); \
|
|
echo "Tagging with version $$next_version";
|
|
git tag $$next_version; \
|
|
git push $(REPO_REMOTE) $$next_version
|