forked from CloudPadovana/caos-dashboard
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_release.sh
executable file
·68 lines (55 loc) · 2.1 KB
/
build_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
#!/usr/bin/env bash
################################################################################
#
# caos-dashboard - CAOS dashboard
#
# Copyright © 2017 INFN - Istituto Nazionale di Fisica Nucleare (Italy)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#
# Author: Fabrizio Chiarello <[email protected]>
#
################################################################################
set -e
PROJECT_DIR=$(dirname $(readlink -f $0))
source ${PROJECT_DIR}/ci-tools/common.sh
GIT_SHA=$(git rev-parse --verify HEAD)
DOCKER_BUILD_IMAGE="node:8.2"
releases_dir=releases
if [ ! -d ${releases_dir} ] ; then
say "Creating %s" ${releases_dir}
mkdir -p ${releases_dir}
fi
container_id=$(docker run -t -d -v $(readlink -e $(pwd)):/origin:ro -v /build -w /build ${DOCKER_BUILD_IMAGE})
say "Started container: %s\n" ${container_id}
function docker_exec () {
docker exec \
-e "DO_PROD_BUILD=true" \
-e "CI_PROJECT_DIR=/build" \
-e "CI_COMMIT_SHA=${GIT_SHA}" \
"$@"
if [ $? != 0 ] ; then
die "Docker error"
fi
}
docker_exec ${container_id} git clone --no-checkout --no-hardlinks /origin /build
docker_exec ${container_id} git checkout -f ${GIT_SHA}
docker_exec ${container_id} ci-tools/prepare.sh
docker_exec ${container_id} ci-tools/release-build.sh
fname=${container_id}:/build/releases/caos_dashboard-$(CI_PROJECT_DIR=. CI_COMMIT_SHA=${GIT_SHA} ci-tools/git-semver.sh).tar.gz
docker cp ${fname} ${releases_dir}/
docker stop ${container_id}
say "Stopped container: %s\n" ${container_id}
docker rm ${container_id}
say "Removed container: %s\n" ${container_id}