Select Git revision
target-version.mk

Volker Schukai authored
target-version.mk 3.63 KiB
#############################################################################################
#############################################################################################
##
## VARIABLES-TARGETS
##
#############################################################################################
#############################################################################################
ifeq ($(VERSION_BIN),)
$(error "$(VERSION_BIN) is not installed. Please check your makefile and include the version.mk")
endif
ifeq ($(GIT),)
$(error $(ERRORMARKER) Git is not defined, check your Makefile if git.mk is included)
endif
ifeq ($(GIT_CHGLOG_BIN),)
$(error $(ERRORMARKER) Chglog is not defined, check your Makefile if changelog.mk is included)
endif
$(VERSION_BIN):
$(QUIET) $(MKDIR) -p $(VENDOR_PATH)
$(QUIET) $(WGET) -O $(VERSION_BIN) http://download.schukai.com/tools/version/version-$(shell uname -s | tr [:upper:] [:lower:])-$(shell echo `uname -m | sed s/aarch64/arm64/ | sed s/x86_64/amd64/`)
$(QUIET) $(CHMOD) u+x $(VERSION_BIN)
.PHONY: next-patch-version
next-patch-version: check-clean-repo $(VERSION_BIN)
$(ECHOMARKER) "Creating next version"
$(QUIET) $(VERSION_BIN) patch --path $(RELEASE_FILE) --selector "version"
$(QUIET) $(GIT) add $(RELEASE_FILE) && $(GIT) commit -m "Bump version to $$(cat $(RELEASE_FILE) | jq -r .version)"
.PHONY: next-minor-version
next-minor-version: check-clean-repo $(VERSION_BIN)
$(ECHOMARKER) "Creating next minor version"
$(QUIET) $(VERSION_BIN) minor --path $(RELEASE_FILE) --selector "version"
$(QUIET) $(GIT) add $(RELEASE_FILE) && $(GIT) commit -m "Bump version to $$( cat $(RELEASE_FILE) | jq -r .version)"
.PHONY: next-major-version
next-major-version: check-clean-repo $(VERSION_BIN)
$(ECHOMARKER) "Creating next minor version"
$(QUIET) $(VERSION_BIN) major --path $(RELEASE_FILE) --selector "version"
$(QUIET) $(GIT) add $(RELEASE_FILE) && $(GIT) commit -m "Bump version to $$(cat $(RELEASE_FILE) | jq -r .version)"
.PHONY: check-clean-repo
check-clean-repo:
$(QUIET) $(GIT) diff-index --quiet HEAD || (echo "There are uncommitted changes after running make. Please commit or stash them before running make."; exit 1)
## tag repository with next patch version
tag-patch-version: $(GIT_CHGLOG_CONFIG_DIR)/config.yml $(GIT_CHGLOG_CONFIG_DIR)/CHANGELOG.tpl.md next-patch-version
$(ECHOMARKER) "Tagging patch version"
$(eval PROJECT_VERSION := $(shell cat $(RELEASE_FILE) | jq -r .version))
$(GIT_CHGLOG_BIN) --next-tag v$(PROJECT_VERSION) -o $(CHANGELOG_FILE)
$(QUIET) $(GIT) add $(CHANGELOG_FILE) && $(GIT) commit -m "Update changelog"
$(QUIET) $(GIT) tag -a v$(PROJECT_VERSION) -m "Version $(PROJECT_VERSION)"
## tag repository with next minor version
tag-minor-version: $(GIT_CHGLOG_CONFIG_DIR)/config.yml $(GIT_CHGLOG_CONFIG_DIR)/CHANGELOG.tpl.md next-minor-version
$(ECHOMARKER) "Tagging minor version"
$(eval PROJECT_VERSION := $(shell cat $(RELEASE_FILE) | jq -r .version))
$(GIT_CHGLOG_BIN) --next-tag v$(PROJECT_VERSION) -o $(CHANGELOG_FILE)
$(QUIET) $(GIT) add $(CHANGELOG_FILE) && $(GIT) commit -m "Update changelog"
$(QUIET) $(GIT) tag -a v$(PROJECT_VERSION) -m "Version $(PROJECT_VERSION)"
## tag repository with next major version
tag-major-version: $(GIT_CHGLOG_CONFIG_DIR)/config.yml $(GIT_CHGLOG_CONFIG_DIR)/CHANGELOG.tpl.md next-major-version
$(ECHOMARKER) "Tagging major version"
$(eval PROJECT_VERSION := $(shell cat $(RELEASE_FILE) | jq -r .version))
$(GIT_CHGLOG_BIN) --next-tag v$(PROJECT_VERSION) -o $(CHANGELOG_FILE)
$(QUIET) $(GIT) add $(CHANGELOG_FILE) && $(GIT) commit -m "Update changelog"
$(QUIET) $(GIT) tag -a v$(PROJECT_VERSION) -m "Version $(PROJECT_VERSION)"