Created
February 15, 2019 01:43
-
-
Save owensengoku/e02d75ccef9cbf59b4b3c8f26c9792fb to your computer and use it in GitHub Desktop.
makefile for version bump
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# for version bump, thanks to alan | |
VERSION := $(shell git describe --tags --abbrev=0 | sed -Ee 's/^v|-.*//') | |
.PHONY: version | |
version: | |
@echo v$(VERSION) | |
SEMVER_TYPES := major minor patch | |
BUMP_TARGETS := $(addprefix bump-,$(SEMVER_TYPES)) | |
.PHONY: $(BUMP_TARGETS) | |
$(BUMP_TARGETS): | |
$(eval bump_type := $(strip $(word 2,$(subst -, ,$@)))) | |
$(eval f := $(words $(shell a="$(SEMVER_TYPES)";echo $${a/$(bump_type)*/$(bump_type)} ))) | |
@echo -n v | |
@echo $(VERSION) | awk -F. -v OFS=. -v f=$(f) '{ $$f++ } 1' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment