-
Notifications
You must be signed in to change notification settings - Fork 9
/
build.sh
executable file
·58 lines (49 loc) · 1.53 KB
/
build.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
#!/usr/bin/env bash
set -o pipefail # trace ERR through pipes
set -o errtrace # trace ERR through 'time command' and other functions
set -o errexit ## set -e : exit the script if any statement returns a non-true return value
get_script_dir () {
SOURCE="${BASH_SOURCE[0]}"
while [[ -h "$SOURCE" ]]; do
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
SOURCE="$( readlink "$SOURCE" )"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE"
done
cd -P "$( dirname "$SOURCE" )"
pwd
}
cd "$(get_script_dir)"
if [[ "$NO_SUDO" || -n "$CIRCLECI" ]]; then
DOCKER="docker"
elif groups "$USER" | grep &>/dev/null '\bdocker\b'; then
DOCKER="docker"
else
DOCKER="sudo docker"
fi
source ./.dockerimage
VCS_REF=$(git describe --tags --dirty)
VERSION=$(git describe --tags --dirty)
docker build --build-arg BUILD_DATE=$(date -Iseconds) \
--build-arg VCS_REF=$VCS_REF \
--build-arg VERSION=$VERSION \
--tag "$IMAGE:latest" \
--tag "$IMAGE:$VERSION" \
.
BUGSNAG_KEY=""
eval $(grep -e "^\\s*BUGSNAG_KEY" Dockerfile | tr '\\' ' ')
if [[ -n "$BUGSNAG_KEY" ]]; then
curl https://build.bugsnag.com/ \
--header "Content-Type: application/json" \
--data "{
\"apiKey\": \"$BUGSNAG_KEY\",
\"appVersion\": \"$VERSION\",
\"releaseStage\": \"dev\",
\"builderName\": \"$USER\",
\"sourceControl\": {
\"provider\": \"github\",
\"repository\": \"https://github.com/LREN-CHUV/woken\",
\"revision\": \"$VCS_REF\"
},
\"metadata\": {}
}"
fi