-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrelease.sh
105 lines (78 loc) · 1.92 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#!/bin/sh
# Thanks Gittip https://github.com/gittip/www.gittip.com
# Fail on error.
# ==============
set -e
# Be somewhere predictable.
# =========================
cd "`dirname $0`"
# --help
# ======
if [ $# = 0 ]; then
echo
echo "Usage: $0 <version>"
echo
echo " This is a release script for Storage."
echo
exit
fi
# Helpers
# =======
confirm () {
proceed=""
while [ "$proceed" != "y" ]; do
read -p"$1 (y/N) " proceed
if [ "$proceed" == "n" -o "$proceed" == "N" -o "$proceed" == "" ]
then
return 1
fi
done
return 0
}
require () {
if [ ! `which $1` ]; then
echo "The '$1' command was not found."
return 1
fi
return 0
}
# Work
# ====
if [ $1 ]; then
require git
if [ $? -eq 1 ]; then
exit
fi
if [ "`git tag | grep '^$1$'`" ]; then
echo "Version $1 is already git tagged."
else
confirm "Tag and push version $1?"
if [ $? -eq 0 ]; then
# Create the release branch
# =========================
git checkout -b release-$1 develop
# Bump the version.
# =================
sed -i "s/v[0-9\.]\+/v$1/" README.md
git commit README.md -m "Bumped version to $1"
# Finish the release
# ==================
git checkout master
git merge --no-ff release-$1
git tag -m "Stable $1" -a $1
# Mirror to develop
# =================
git checkout develop
git merge --no-ff release-$1
# Push to GitHub.
# ===============
# This will break if we didn't pull before releasing. We should do
# that.
git push
git push --tags
# Delete Branch
# =============
git branch -d release-$1
fi
fi
fi