author | ymh <ymh.work@gmail.com> |
Tue, 18 Oct 2016 18:42:13 +0200 | |
changeset 367 | e0fb97c1e9c6 |
parent 346 | 4cd0f8c936ed |
child 368 | 5f79f31ca9a2 |
permissions | -rwxr-xr-x |
346
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1 |
#!/usr/bin/env bash |
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
2 |
|
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
3 |
set -e |
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
4 |
## option --prod/--dev |
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
5 |
|
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
6 |
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" |
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
7 |
|
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
8 |
VAGRANT_STARTED=false |
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
9 |
|
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
10 |
green="\x1B[0;32m" # '\e[1;32m' is too bright for white bg. |
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
11 |
blue="\x1B[1;34m" |
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
12 |
endColor="\x1B[0m" |
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
13 |
|
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
14 |
function echoblue() { |
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
15 |
echo -e "${blue}$1${endColor}" |
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
16 |
} |
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
17 |
|
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
18 |
function install() { |
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
19 |
pushd "$DIR" |
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
20 |
|
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
21 |
echoblue "---> preparing bo client" |
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
22 |
pushd ../server/bo_client |
367
e0fb97c1e9c6
correct build script + rpm hook scripts
ymh <ymh.work@gmail.com>
parents:
346
diff
changeset
|
23 |
/usr/local/bin/npm install |
346
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
24 |
./node_modules/.bin/bower install |
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
25 |
popd |
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
26 |
echoblue "---> preparing bo client done" |
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
27 |
|
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
28 |
echoblue "---> preparing back" |
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
29 |
pushd ../server/src |
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
30 |
php composer.phar install |
367
e0fb97c1e9c6
correct build script + rpm hook scripts
ymh <ymh.work@gmail.com>
parents:
346
diff
changeset
|
31 |
/usr/local/bin/npm install |
346
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
32 |
./node_modules/.bin/bower install |
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
33 |
popd |
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
34 |
echoblue "---> preparing back done" |
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
35 |
|
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
36 |
echoblue "---> preparing app-client" |
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
37 |
pushd ../cms/app-client |
367
e0fb97c1e9c6
correct build script + rpm hook scripts
ymh <ymh.work@gmail.com>
parents:
346
diff
changeset
|
38 |
/usr/local/bin/npm install |
346
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
39 |
./node_modules/.bin/bower install |
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
40 |
popd |
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
41 |
echoblue "---> preparing app-client done" |
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
42 |
|
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
43 |
echoblue "---> preparing module" |
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
44 |
pushd ../cms |
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
45 |
npm install |
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
46 |
|
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
47 |
|
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
48 |
echoblue "---> checking vagrant" |
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
49 |
if vagrant status | grep -q "running"; then |
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
50 |
echoblue "---> starting vagrant" |
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
51 |
vagrant up |
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
52 |
VAGRANT_STARTED=true |
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
53 |
fi |
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
54 |
|
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
55 |
echoblue "---> done" |
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
56 |
|
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
57 |
popd |
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
58 |
|
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
59 |
} |
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
60 |
|
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
61 |
function usage() { |
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
62 |
cat <<EOF |
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
63 |
Usage: $0 [-I] [-p|-d] [-h] |
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
64 |
-I : do not run install |
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
65 |
-h : print this message |
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
66 |
-p : build for production |
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
67 |
-d : build for development |
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
68 |
EOF |
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
69 |
} |
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
70 |
|
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
71 |
environment="" |
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
72 |
do_install=true |
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
73 |
|
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
74 |
|
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
75 |
while getopts "Ihpd" opt; do |
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
76 |
case $opt in |
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
77 |
I) do_install=false ;; |
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
78 |
h) usage; exit 0 ;; |
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
79 |
p) [[ -n "$environment" ]] && { usage >&2; exit 1; } || environment='production' ;; |
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
80 |
d) [[ -n "$environment" ]] && { usage >&2; exit 1; } || environment='development' ;; |
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
81 |
\?) usage >&2; exit 1 ;; |
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
82 |
esac |
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
83 |
done |
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
84 |
shift $((OPTIND-1)) |
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
85 |
|
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
86 |
[[ -z "$environment" ]] && environment='production' |
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
87 |
|
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
88 |
case $environment in |
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
89 |
development) build_option='--dev' ;; |
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
90 |
*) build_option='--prod' ;; |
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
91 |
esac |
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
92 |
|
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
93 |
echo "environment: $environment" |
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
94 |
echo "do_install: $do_install" |
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
95 |
[[ "$do_install" == true ]] && echoblue "DO INSTALL" && install; |
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
96 |
|
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
97 |
pushd "$DIR" |
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
98 |
|
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
99 |
echoblue "---> cleaning build folder" |
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
100 |
rm -fr root |
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
101 |
|
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
102 |
echoblue "---> creating build folder" |
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
103 |
mkdir -p root/var/www/corpusdelaparole/corpus-back |
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
104 |
mkdir -p root/var/www/corpusdelaparole/drupal/sites/all/modules |
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
105 |
|
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
106 |
echoblue "---> buiding back" |
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
107 |
pushd ../server/src |
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
108 |
version=$(sed -n "s/[[:space:]]*\'version\'[[:space:]]*=>[[:space:]]*\'\([\.0-9]*\)\'/\1/p" config/version.php) |
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
109 |
version=${version:-0.0.0} |
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
110 |
./node_modules/.bin/gulp copy-build ${build_option} |
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
111 |
popd |
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
112 |
echoblue "---> buiding back done" |
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
113 |
|
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
114 |
echoblue "---> building app-client" |
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
115 |
pushd ../cms/app-client |
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
116 |
./node_modules/.bin/ember build ${build_option} |
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
117 |
popd |
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
118 |
echoblue "---> building app-client done" |
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
119 |
|
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
120 |
echoblue "---> building module" |
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
121 |
pushd ../cms |
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
122 |
./node_modules/.bin/gulp copy-build ${build_option} --version="$version" |
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
123 |
popd |
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
124 |
|
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
125 |
echoblue "---> building package" |
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
126 |
vagrant ssh -c "/vagrant/build_rpm.sh" |
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
127 |
|
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
128 |
echoblue "---> done" |
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
129 |
|
4cd0f8c936ed
upgrade build and delivery process for integration
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
130 |
popd |