/
release.sh
executable file
·48 lines (41 loc) · 1.31 KB
/
release.sh
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
#!/bin/sh
function usage () {
echo "$1"
exit
}
APPSRC=`echo $PWD/src/*.app.src`
BRANCH=$(git rev-parse --abbrev-ref HEAD)
TAG=$(git name-rev --tags --name-only $(git rev-parse HEAD))
OVSN=$(git describe | cut -f1 -d"-")
[ -f $APPSRC ] || usage "No .app.src file"
[ "$BRANCH" != "master" ] && usage "Not on master"
[ "$TAG" != "undefined" ] && usage "Already tagged"
[ "$OVSN" = "" ] && usage "No old version"
if [ -z "$1" ]; then
size="patch"
else
size=$1
fi
MAJOR=`echo $OVSN | cut -f1 -d"."`
MINOR=`echo $OVSN | cut -f2 -d"."`
PATCH=`echo $OVSN | cut -f3 -d"."`
if [ "$size" == "major" ]; then
NVSN=$(($MAJOR + 1)).0.0
elif [ "$size" == "minor" ]; then
NVSN=$MAJOR.$(($MINOR + 1)).0
elif [ "$size" == "patch" ]; then
NVSN=$MAJOR.$MINOR.$(($PATCH + 1))
else
usage "$0 major|minor|patch"
fi
echo $OVSN"->"$NVSN
sed "s/[0-9]\.[0-9]\.[0-9]/$NVSN/" < $APPSRC > $$ && mv $$ $APPSRC
git add $APPSRC
git commit -m"v$NVSN"
git log --name-only --no-merges | grep -Ev '^[ ]+$$|git-svn-id' > ChangeLog
echo " Mats Cronqvist <masse@cronqvi.st>" > AUTHORS
git log | grep Author | grep -Evi "vagrant|no author|mats cronqvist" \
| sort -u | cut -c8- >> AUTHORS
git add ChangeLog AUTHORS
git commit --amend --reuse-message HEAD
git tag -a -m"$NVSN" $NVSN && echo "git push && git push --tags"