From baa109963380f7f04025807f8ce38056728492c2 Mon Sep 17 00:00:00 2001 From: facundoolano Date: Wed, 28 Feb 2024 11:12:17 -0300 Subject: [PATCH] add makefile target to manage versioning --- Makefile | 35 +++++++++++++++++++++++++++++++++++ docs/Makefile | 3 --- 2 files changed, 35 insertions(+), 3 deletions(-) create mode 100644 Makefile delete mode 100644 docs/Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..d4f9376 --- /dev/null +++ b/Makefile @@ -0,0 +1,35 @@ +.PHONY: bump_version major minor patch + +major: + @$(MAKE) TYPE=major bump_version + +minor: + @$(MAKE) TYPE=minor bump_version + +patch: + @$(MAKE) TYPE=patch bump_version + +CURRENT=$(shell git describe --tags --abbrev=0) +MAJOR=$(shell echo $(CURRENT) | cut -d. -f1) +MINOR=$(shell echo $(CURRENT) | cut -d. -f2) +PATCH=$(shell echo $(CURRENT) | cut -d. -f3) +ifeq ($(TYPE),major) + NEW_VERSION := $(shell echo $(MAJOR)+1 | bc).0.0 +else ifeq ($(TYPE),minor) + NEW_VERSION := $(MAJOR).$(shell echo $(MINOR)+1 | bc).0 +else ifeq ($(TYPE),patch) + NEW_VERSION := $(MAJOR).$(MINOR).$(shell echo $(PATCH)+1 | bc) +endif +bump_version: + @echo "Bumping version to $(NEW_VERSION)" + @sed -i '' -e 's/"version": "jorge v.*"/"version": "jorge v$(NEW_VERSION)"/' main.go + git add main.go + git commit -m "v$(NEW_VERSION)" + git tag -a $(NEW_VERSION) -m "v$(NEW_VERSION)" + git push origin + git push origin --tags + make docs + +docs: + jorge build docs + rsync -vPrz --delete docs/target/ root@olano.dev:/var/www/jorge diff --git a/docs/Makefile b/docs/Makefile deleted file mode 100644 index 4c9bfd1..0000000 --- a/docs/Makefile +++ /dev/null @@ -1,3 +0,0 @@ -deploy: - jorge build - rsync -vPrz --delete target/ root@olano.dev:/var/www/jorge