This repository has been archived by the owner on Jul 15, 2023. It is now read-only.
/
Makefile
74 lines (62 loc) · 2.71 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# This script will be executed after commit in placed in .git/hooks/post-commit
# Semantic Versioning 2.0.0 guideline
#
# Given a version number MAJOR.MINOR.PATCH, increment the:
# MAJOR version when you make incompatible API changes,
# MINOR version when you add functionality in a backwards-compatible manner, and
# PATCH version when you make backwards-compatible bug fixes.
# Reset
Color_Off=\033[0m
Cyan=\033[0;36m
Green=\033[0;32m
VERSION:=$(shell git describe --tags --abbrev=0)
MAJOR=$(shell echo ${VERSION} | cut -d'.' -f1)
MINOR=$(shell echo ${VERSION} | cut -d'.' -f2)
PATCH=$(shell echo ${VERSION} | cut -d'.' -f3)
# Returns the string 'v' if exists, or empty if otherwise.
PREFIX=$(findstring v,$(VERSION))
major:
$(eval MAJOR=$(shell echo $$(($(MAJOR)+1))))
@echo
@echo "Next $(Green)MAJOR$(Color_Off) version: $(VERSION) ~> $(PREFIX)$(Green)$(MAJOR)$(Color_Off).$(MINOR).$(PATCH)"
@echo "Run $(Cyan)make bump-major$(Color_Off) to bump the version."
@echo
minor:
@# This is required to get rid of the version prefix 'v'.
$(eval MAJOR=$(shell echo $$(($(MAJOR)+0))))
$(eval MINOR=$(shell echo $$(($(MINOR)+1))))
@echo
@echo "Next $(Green)MINOR$(Color_Off) version: $(VERSION) ~> $(PREFIX)$(MAJOR).$(Green)$(MINOR)$(Color_Off).$(PATCH)"
@echo "Run $(Cyan)make bump-minor$(Color_Off) to bump the version."
@echo
patch:
@# This is required to get rid of the version prefix 'v'.
$(eval MAJOR=$(shell echo $$(($(MAJOR)+0))))
$(eval PATCH=$(shell echo $$(($(PATCH)+1))))
@echo
@echo "Next $(Green)PATCH$(Color_Off) version: $(VERSION) ~> $(PREFIX)$(MAJOR).$(MINOR).$(Green)$(PATCH)$(Color_Off)"
@echo "Run $(Cyan)make bump-patch$(Color_Off) to bump the version."
@echo
bump-major:
$(eval MAJOR=$(shell echo $$(($(MAJOR)+1))))
@echo
@echo "Bumping $(Green)MAJOR$(Color_Off) version: $(VERSION) ~> $(PREFIX)$(Green)$(MAJOR)$(Color_Off).$(MINOR).$(PATCH)"
$(eval NEXT_VERSION=$(PREFIX)$(MAJOR).$(MINOR).$(PATCH))
git tag -a $(NEXT_VERSION) -m "Release $(NEXT_VERSION)"
git push origin --tags
bump-minor:
$(eval MAJOR=$(shell echo $$(($(MAJOR)+0))))
$(eval MINOR=$(shell echo $$(($(MINOR)+1))))
@echo
@echo "Bumping $(Green)MINOR$(Color_Off) version: $(VERSION) ~> $(PREFIX)$(MAJOR).$(Green)$(MINOR)$(Color_Off).$(PATCH)"
$(eval NEXT_VERSION=$(PREFIX)$(MAJOR).$(MINOR).$(PATCH))
git tag -a $(NEXT_VERSION) -m "Release $(NEXT_VERSION)"
git push origin --tags
bump-patch:
$(eval MAJOR=$(shell echo $$(($(MAJOR)+0))))
$(eval PATCH=$(shell echo $$(($(PATCH)+1))))
@echo
@echo "Bumping $(Green)PATCH$(Color_Off) version: $(VERSION) ~> $(PREFIX)$(MAJOR).$(MINOR).$(Green)$(PATCH)$(Color_Off)"
$(eval NEXT_VERSION=$(PREFIX)$(MAJOR).$(MINOR).$(PATCH))
git tag -a $(NEXT_VERSION) -m "Release $(NEXT_VERSION)"
git push origin --tags