From d3928a34123a81f7e6cd438dd2cd64a10cd9790a Mon Sep 17 00:00:00 2001 From: christophercarlon Date: Wed, 18 Sep 2024 21:52:34 +0100 Subject: [PATCH] makefile change --- makefile | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/makefile b/makefile index 56c3ffd..ec36a78 100644 --- a/makefile +++ b/makefile @@ -1,20 +1,34 @@ -# Makefile for Nebby GitHub Release and Tagging - # Variables VERSION := $(shell cargo pkgid | cut -d\# -f2 | cut -d: -f2) +FORCE_TAG := false .PHONY: release release: @echo "Creating release $(VERSION)..." @if [ -z "$(VERSION)" ]; then echo "Error: VERSION is not set"; exit 1; fi - # Create a new tag - git tag -a v$(VERSION) -m "Release version $(VERSION)" - git push origin v$(VERSION) - # Prompt for release notes - @echo "Please enter release notes (press Ctrl+D when finished):" + + # Check if tag exists + @if git rev-parse v$(VERSION) >/dev/null 2>&1; then \ + if [ "$(FORCE_TAG)" = "true" ]; then \ + echo "Updating tag v$(VERSION)..."; \ + git tag -fa v$(VERSION) -m "Release version $(VERSION)"; \ + git push -f origin v$(VERSION); \ + else \ + echo "Tag v$(VERSION) exists. Use FORCE_TAG=true to override."; \ + exit 1; \ + fi; \ + else \ + echo "Creating tag v$(VERSION)..."; \ + git tag -a v$(VERSION) -m "Release version $(VERSION)"; \ + git push origin v$(VERSION); \ + fi + + # Get release notes + @echo "Enter release notes (Ctrl+D to finish):" @NOTES=$$(cat); \ - gh release create v$(VERSION) \ - --title "Nebby v$(VERSION)" \ - --notes "$$NOTES" - @echo "Release v$(VERSION) created and published on GitHub" + gh release create v$(VERSION) --title "Nebby v$(VERSION)" --notes "$$NOTES" \ + $$(if [ "$(FORCE_TAG)" = "true" ]; then echo "--target main"; fi) || \ + { echo "Error: Failed to create GitHub release."; exit 1; } + + @echo "Release v$(VERSION) published on GitHub"