-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathversion.sh
More file actions
executable file
·55 lines (42 loc) · 845 Bytes
/
version.sh
File metadata and controls
executable file
·55 lines (42 loc) · 845 Bytes
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
#!/bin/bash
# Originally copied from https://github.com/fmahnke/shell-semver
# => Copyright (c) 2014 Fritz Mahnke
# Increment a version string using Semantic Versioning (SemVer) terminology.
# Parse command line options.
while getopts ":Mmp" Option
do
case $Option in
M ) major=true;;
m ) minor=true;;
p ) patch=true;;
esac
done
shift $(($OPTIND - 1))
# if [ ! -z "$1" ]; then
# TAG_MSG="-m '$1'"
# fi
version=$(git describe --tags)
version=${version#v}
version=${version%%-*}
# Build array from version string.
a=( ${version//./ } )
# Increment version numbers as requested.
if [ ! -z $major ]
then
((a[0]++))
a[1]=0
a[2]=0
fi
if [ ! -z $minor ]
then
((a[1]++))
a[2]=0
fi
if [ ! -z $patch ]
then
((a[2]++))
fi
next="v${a[0]}.${a[1]}.${a[2]}"
msg=${1:-$next}
git tag -s -a "$next" -m "$msg"
echo $next