Skip to content

Instantly share code, notes, and snippets.

@owensengoku
Created February 15, 2019 01:43
Show Gist options
  • Save owensengoku/e02d75ccef9cbf59b4b3c8f26c9792fb to your computer and use it in GitHub Desktop.
Save owensengoku/e02d75ccef9cbf59b4b3c8f26c9792fb to your computer and use it in GitHub Desktop.
makefile for version bump
# 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