-
Notifications
You must be signed in to change notification settings - Fork 0
/
mkeye2-trealla
executable file
·73 lines (59 loc) · 1.48 KB
/
mkeye2-trealla
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
#!/bin/bash
# check the command line
if [ $# -lt 2 ] ; then
echo "Missing release options and release message";
echo "usage: $(basename $0) [-Mmp] \"release message\""
exit 1
fi
# change working directory
pushd ~/github.com/eyereasoner/eye2-trealla > /dev/null
# the following is adapted from https://gist.github.com/codezninja/c227d9c65b09d2be2d99abbfcfa8774a
while getopts "Mmp" Option
do
case $Option in
M ) major=true;;
m ) minor=true;;
p ) patch=true;;
* ) exit 1;;
esac
done
# if a flag is missing, show usage message
if [ $OPTIND -eq 1 ]; then
echo "No release options were passed: -M for major, -m for minor and -p for patch";
echo "usage: $(basename $0) [-Mmp] \"release message\""
exit 1
fi
shift $(($OPTIND - 1))
version=$(cat 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
echo "${a[0]}.${a[1]}.${a[2]}" > VERSION
export RELEASE="v$(cat VERSION)"
export DATE="$(date -Idate)"
# update version in eye2-trealla.pl
cat eye2-trealla.pl | sed -e "s/'eye2-trealla.*'/'eye2-trealla $RELEASE \($DATE\)'/" > eye2-trealla.pl.tmp
mv eye2-trealla.pl.tmp eye2-trealla.pl
# run the etc tests
pushd etc > /dev/null
./test
git diff
popd > /dev/null
# git commands
git commit -a -m "$1"
git push
git tag -a -m "$1" $RELEASE
git push origin $RELEASE
popd > /dev/null