This repository has been archived by the owner on Mar 1, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathtest-package.sh
executable file
·161 lines (135 loc) · 3.72 KB
/
test-package.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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
#! /bin/bash
#
# Postfacto, a free, open-source and self-hosted retro tool aimed at helping
# remote teams.
#
# Copyright (C) 2016 - Present Pivotal Software, Inc.
#
# This program is free software: you can redistribute it and/or modify
#
# it under the terms of the GNU Affero General Public License as
#
# published by the Free Software Foundation, either version 3 of the
#
# License, or (at your option) any later version.
#
#
#
# This program is distributed in the hope that it will be useful,
#
# but WITHOUT ANY WARRANTY; without even the implied warranty of
#
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#
# GNU Affero General Public License for more details.
#
#
#
# You should have received a copy of the GNU Affero General Public License
#
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
if [[ ! $* =~ --skip-package ]];
then
"$SCRIPT_DIR/package.sh"
fi
if [[ ! $* =~ --skip-heroku ]];
then
heroku whoami \
|| (echo 'You need to have the Heroku CLI installed and be logged in' \
&& exit 1)
fi
if [[ ! $* =~ --skip-cf ]];
then
cf target \
|| (echo 'You need to have the CF CLI installed and be logged in' \
&& exit 1)
fi
if [[ ! $* =~ --skip-upgrade ]];
then
curl -L -o "$SCRIPT_DIR/last-release.zip" 'https://github.com/pivotal/postfacto/releases/latest/download/package.zip'
unzip "$SCRIPT_DIR/last-release.zip" -d "$SCRIPT_DIR/last-release"
fi
unzip "$SCRIPT_DIR/package.zip"
echo 'Setup complete'
NOW=$(date +%s)
OLD_APP="postfacto-old-app-${NOW}"
NEW_APP="postfacto-new-app-${NOW}"
if [[ ! $* =~ --skip-cf ]];
then
echo '####### Cloud Foundry'
SPACE="postfacto-space-${NOW}"
cf create-space $SPACE
cf target -s $SPACE
cf create-service \
"${REDIS_SERVICE:-p-redis}" \
"${REDIS_PLAN:-shared-vm}" \
postfacto-redis
cf create-service \
"${DB_SERVICE:-p.mysql}" \
"${DB_PLAN:-db-small}" \
postfacto-db
while [[ $(cf services) =~ 'create in progress' ]];
do
echo 'Service creation in progress'
sleep 5
done
pushd "$SCRIPT_DIR/package/cf"
echo 'Deploying new version to Cloud Foundry'
ENABLE_ANALYTICS=false ./deploy.sh "$NEW_APP"
popd
if [[ ! $* =~ --skip-upgrade ]];
then
pushd "$SCRIPT_DIR/last-release/package/cf"
echo 'Deploying old version to Cloud Foundry'
ENABLE_ANALYTICS=false ./deploy.sh "$OLD_APP"
popd
pushd "$SCRIPT_DIR/package/cf"
echo 'Upgrading old version on Cloud Foundry'
ENABLE_ANALYTICS=false ./upgrade.sh "$OLD_APP"
popd
fi
echo 'Cleaning up Cloud Foundry'
for APP in $NEW_APP $OLD_APP
do
cf delete "$APP" -f -r
done
for SERVICE in 'postfacto-redis' 'postfacto-db'
do
cf delete-service $SERVICE -f
done
while [[ $(cf services) =~ 'delete in progress' ]];
do
echo 'Service deletion in progress'
sleep 5
done
cf delete-space "$SPACE" -f
fi
if [[ ! $* =~ --skip-heroku ]];
then
echo '####### Heroku'
pushd "$SCRIPT_DIR/package/heroku"
echo 'Deploying new version to Heroku'
ENABLE_ANALYTICS=false ./deploy.sh "$NEW_APP"
popd
if [[ ! $* =~ --skip-upgrade ]];
then
pushd "$SCRIPT_DIR/last-release/package/heroku"
echo 'Deploying old version to Heroku'
ENABLE_ANALYTICS=false ./deploy.sh "$OLD_APP"
popd
pushd "$SCRIPT_DIR/package/heroku"
echo 'Upgrading old version on Heroku'
ENABLE_ANALYTICS=false ./upgrade.sh "$OLD_APP"
popd
fi
echo 'Cleaning up Heroku'
for APP in $NEW_APP $OLD_APP
do
heroku apps:delete -a "$APP" -c "$APP" || echo "$APP not found"
done
fi
echo 'Cleaning up working directory'
rm -rf "$SCRIPT_DIR/last-release" "$SCRIPT_DIR/last-release.zip" "$SCRIPT_DIR/package"