build: add tag tasks

This commit is contained in:
2026-01-23 00:45:54 +02:00
parent b61dbc6d15
commit 2a0c1c7c22
2 changed files with 53 additions and 0 deletions

10
.editorconfig Normal file
View File

@@ -0,0 +1,10 @@
# EditorConfig for Makefile
root = true
[Makefile]
indent_style = tab
indent_size = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

43
Makefile Normal file
View File

@@ -0,0 +1,43 @@
.PHONY: tag help
help:
@echo "Usage: make tag [TAG=<name>] [VERSION=<number>]"
@echo ""
@echo " TAG - Tag prefix name (e.g., 'go-release', 'nextcloud')"
@echo " Can also be set via TAG env var"
@echo " VERSION - Version number (optional, auto-increments if omitted)"
@echo ""
@echo "Examples:"
@echo " make tag TAG=go-release"
@echo " make tag TAG=go-release VERSION=3"
@echo " TAG=nextcloud make tag"
tag:
ifndef TAG
$(error TAG is required. Usage: make tag TAG=<name> [VERSION=<number>])
endif
@# Auto-detect version if not provided
$(eval VERSION ?= $(shell \
latest=$$(git tag --list '$(TAG)-v*' | sed 's/$(TAG)-v//' | sort -n | tail -1); \
if [ -z "$$latest" ]; then echo 1; else echo $$((latest + 1)); fi \
))
@# Get latest global version
$(eval GLOBAL_VERSION := $(shell \
latest=$$(git tag --list 'v*' | grep -E '^v[0-9]+$$' | sed 's/v//' | sort -n | tail -1); \
if [ -z "$$latest" ]; then echo 1; else echo $$((latest + 1)); fi \
))
@echo "Tagging with:"
@echo " Global version: v$(GLOBAL_VERSION)"
@echo " Tag version: $(TAG)-v$(VERSION)"
@echo " Latest tag: $(TAG)-latest"
@echo ""
@# Create global version tag
git tag -f v$(GLOBAL_VERSION)
@# Create tag-specific version
git tag -f $(TAG)-v$(VERSION)
@# Remove old latest tag and re-create
-git tag -d $(TAG)-latest 2>/dev/null || true
git tag $(TAG)-latest
@echo ""
@echo "Tags created successfully!"
@echo "To push tags, run: git push origin v$(GLOBAL_VERSION) $(TAG)-v$(VERSION) $(TAG)-latest --force"