Skip to content

Commit

Permalink
Add Makefile functions for semver manipulation
Browse files Browse the repository at this point in the history
  • Loading branch information
gkze committed Apr 13, 2020
1 parent b43b307 commit 236cf39
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
VERSION_FILE = VERSION

define bump_major
awk -F. '{printf "%s.%s.%s\n", $$1+1, $$2, $$3}' $(VERSION_FILE)
endef

define bump_minor
awk -F. '{printf "%s.%s.%s\n", $$1, $$2+1, $$3}' $(VERSION_FILE)
endef

define bump_patch
awk -F. '{printf "%s.%s.%s\n", $$1, $$2, $$3+1}' $(VERSION_FILE)
endef

# Display this help message
.PHONY: help
help:
Expand Down Expand Up @@ -28,23 +42,23 @@ release:
# Do a major release
.PHONY: release-major
release-major:
@echo $(shell awk -F. '{printf "%s.%s.%s\n", $$1+1, $$2, $$3}' VERSION) > VERSION
@echo $(shell $(call bump_major)) > VERSION
@git add VERSION
@git commit -S -m "Release $(shell cat VERSION)"
@git commit -S -m "Release $(shell $(call bump_major))"
$(MAKE) release

# Do a minor release
.PHONY: release-minor
release-minor:
@echo $(shell awk -F. '{printf "%s.%s.%s\n", $$1, $$2+1, $$3}' VERSION) > VERSION
@echo $(shell $(call bump_minor)) > VERSION
@git add VERSION
@git commit -S -m "Release $(shell cat VERSION)"
@git commit -S -m "Release $(shell $(call bump_minor))"
$(MAKE) release

# Do a patch release
.PHONY: release-patch
release-patch:
@echo $(shell awk -F. '{printf "%s.%s.%s\n", $$1, $$2, $$3+1}' VERSION) > VERSION
@echo $(shell $(call bump_patch)) > VERSION
@git add VERSION
@git commit -S -m "Release $(shell cat VERSION)"
@git commit -S -m "Release $(shell $(call bump_patch))"
$(MAKE) release

0 comments on commit 236cf39

Please sign in to comment.