added makefile to do releases
All checks were successful
Go / build (1.23) (push) Successful in 28s

This commit is contained in:
Colin Henry 2024-10-27 12:04:01 -07:00
parent 40bc496b20
commit 7e1daaf7d5

View File

@ -0,0 +1,20 @@
# Variables
REPO_REMOTE := origin
VERSION_TAG_PREFIX := "v" # Prefix for version tags, if any
# 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 "$(VERSION_TAG_PREFIX)0.0.0"); \
major=$$(echo $$latest_tag | sed -E 's/$(VERSION_TAG_PREFIX)([0-9]+)\.[0-9]+\.[0-9]+/\1/'); \
minor=$$(echo $$latest_tag | sed -E 's/$(VERSION_TAG_PREFIX)[0-9]+\.([0-9]+)\.[0-9]+/\1/'); \
patch=$$(echo $$latest_tag | sed -E 's/$(VERSION_TAG_PREFIX)[0-9]+\.[0-9]+\.([0-9]+)/\1/'); \
next_patch=$$(($$patch + 1)); \
echo "$(VERSION_TAG_PREFIX)$$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