forked from gratipay/gratipay.com
-
Notifications
You must be signed in to change notification settings - Fork 6
/
release.sh
executable file
·107 lines (78 loc) · 2.08 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
#!/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
# Bump the version.
# =================
printf "$1" > www/version.txt
git commit www/version.txt -m"Bump version to $1"
git tag $1
# Deploy to Heroku.
# =================
# If this fails we still want to bump the version again, so modify
# bash error handling around this call.
set +e
git push heroku master
set -e
# 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 "\055dev" >> www/version.txt
git commit www/version.txt -m"Bump version to $1-dev"
# Push to GitHub.
# ===============
# This will break if we didn't pull before releasing. We should do
# that.
git push
git push --tags
fi
fi
fi