-
Notifications
You must be signed in to change notification settings - Fork 0
/
release.sh
executable file
·50 lines (42 loc) · 1.17 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
49
50
#!/bin/bash
#
# Tag release and push to origin remotes.
#
if [ $# -ne 1 ]
then
echo "Tag and push master to 'origin' remotes"
echo "Usage: `basename $0` version"
exit 1
fi
version="$1"
current_branch=`git rev-parse --abbrev-ref HEAD`
# Check we are on master branch
if [ "$current_branch" != "master" ]
then
echo -e "$0 only works from *master* branch. When ready, Please run \n\tgit checkout master\n\t$0"
exit 1
fi
# Check there is no pending changes --> branch is clean
if [ -n "`git status --porcelain`" ]
then
echo "There are pending/uncommited changes in current branch."
echo "Please commit or stash them."
exit 1
fi
# Ensure commit is tagged and annotated
current_tag=$(git describe --exact-match 2>/dev/null)
if [ -n "$current_tag" ]
then
if [ "$current_tag" != "v$version" ]
then
echo "Error: version mismatch '$current_tag' != 'v$version'"
fi
else
sed -i.bak "s/const Version =.*/const Version = \"$version\"/g" venom.go
rm -f venom.go.bak
git commit -am "[auto] bump version to v$version"
git tag -s "v$version"
fi
echo "Pushing master and 'v$version'"
git push origin master
git push origin "v$version"