forked from gratipay/gratipay.com
-
Notifications
You must be signed in to change notification settings - Fork 0
/
release.sh
executable file
·121 lines (84 loc) · 2.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
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#!/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 " www/version.txt 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."
exit 1
fi
}
# Work
# ====
if [ $1 ]; then
require heroku
require git
if [ "`git rev-parse --abbrev-ref HEAD`" != "master" ]; then
echo "Not on master, checkout master first."
exit
fi
# Make sure we have the latest master.
# ====================================
git pull
if [ "`git tag | grep $1`" ]; then
echo "Version $1 is already git tagged."
exit
fi
if ! grep -e \-dev$ www/version.txt > /dev/null; then
echo "Current version does not end with '-dev'."
exit
fi
confirm "Tag and push version $1?"
if [ $? -eq 0 ]; then
# Check that the environment contains all required variables.
# ===========================================================
heroku config -sa gittip | ./env/bin/honcho run -e /dev/stdin \
./env/bin/python gittip/wireup.py
# Bump the version.
# =================
printf "$1\n" > www/version.txt
git commit www/version.txt -m"Bump version to $1"
git tag $1
# Deploy to Heroku.
# =================
git push heroku master
# Bump the version again.
# =======================
# We're using a Pythonic convention here by using -dev to mean, "a
# dev version following $whatever." We escape the dash for bash's
# sake
printf "$1\055dev\n" > www/version.txt
git commit www/version.txt -m"Bump version to $1-dev"
# Push to GitHub.
# ===============
git push
git push --tags
fi
fi