forked from gratipay/gratipay.com
-
Notifications
You must be signed in to change notification settings - Fork 0
/
release.sh
executable file
·97 lines (71 loc) · 1.8 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
#!/bin/sh
# 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 Gittip. We bump the version number in "
echo " gittip/__init__.py and then do a git dance, pushing to Heroku."
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
# Fix the version.
# ================
sed -e "s/~~VERSION~~/$1/" -i '' gittip/__init__.py
git ci gittip/__init__.py \
-m"Setting version to $1 in gittip/__init__.py."
git tag $1
# Deploy to Heroku.
# =================
# If this fails we still want to reset the version, so modify bash
# error handling around this call.
set +e
git push heroku
set -e
# Change the version back.
# ========================
sed -e "s/$1/~~VERSION~~/" -i '' gittip/__init__.py
git ci gittip/__init__.py \
-m"Resetting version in gittip/__init__.py."
fi
fi
fi