-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
38 lines (31 loc) · 1009 Bytes
/
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
SHELL=/bin/bash
.PHONY := major minor patch
.DEFAULT_GOAL := patch
PKG = snm
RE=[^0-9]*\([0-9]*\)[.]\([0-9]*\)[.]\([0-9]*\)\([0-9A-Za-z-]*\)
version = $(subst v,,$(shell git describe --tags --abbrev=0))
major_ver = $(shell (echo $(version) | sed -e 's#$(RE)#\1#'))
minor_ver = $(shell (echo $(version) | sed -e 's#$(RE)#\2#'))
patch_ver = $(shell (echo $(version) | sed -e 's#$(RE)#\3#'))
define release
echo "-- Old Tag: $(version)"
echo "-- New Tag: $(1)"
echo ""
echo ">> Updating Cargo.toml"
sed -i -e 's/^version = .*/version = $(1)/g' Cargo.toml
echo ">> Updating Cago.lock"
cargo update -p $(PKG)
echo ">> Release: $(1)"
git commit -a -m "Release $(1)"
git tag v$(1) -m "Release $(1)"
echo ">> Push Tags"
git push --tags
echo ">> All mighty push"
git push
endef
major:
@$(call release,"$(shell expr $(major_ver) + 1).0.0")
minor:
@$(call release,"$(major_ver).$(shell expr $(minor_ver) + 1).0")
patch:
@$(call release,"$(major_ver).$(minor_ver).$(shell expr $(patch_ver) + 1)")