-
Notifications
You must be signed in to change notification settings - Fork 0
/
git-tag.sh
executable file
·63 lines (46 loc) · 1.25 KB
/
git-tag.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/bin/bash
# this is for macOS
[ -x /usr/local/bin/gsed ] && sed=/usr/local/bin/gsed || sed=sed
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
lasthash=`git log --decorate=full --all --pretty=format:'%h %d' |grep 'refs/tags'|head -1|awk '{print $1}'`
lasttag=`git describe --tags $lasthash`
if [ "$#" -ne 1 ]
then
echo ""
echo "Usage: $0 <new version>"
echo ""
echo "Previous version: ${lasttag}"
exit 1
fi
newtag="$1"
if [[ $newtag =~ [0-9]+[.][0-9]+$ ]] ; then
echo "New version: $newtag"
else
echo "Invalid version: $newtag, aborting"
exit 1
fi
if [ `git tag|grep $newtag` ] ; then
echo "$newtag already exists, aborting"
exit 2
fi
GITTOP=`git rev-parse --show-toplevel`
lastdate=`git log -1 --format=%ci`
if [ `git status --short|wc -l` -ne 0 ] ; then
git status --short
echo "It seems there are not commited changes, please check"
fi
echo ""
echo "$newtag" > tag.txt
sed -i "s/^VERSION.*/VERSION='$newtag'/" kafkatop.py
git diff
git add tag.txt
git add kafkatop.py
read -p "Press [Enter] key commit changes:"
git commit -m "$newtag in tag.txt"
git push
echo ""
#read -p "Press [Enter] key to tag ${newtag}: "
git tag -a $newtag -m "Version ${newtag}"
echo ""
#read -p "Press [Enter] key to push tags: "
git push --tags