-
Notifications
You must be signed in to change notification settings - Fork 0
/
travis.sh
executable file
·96 lines (79 loc) · 2.02 KB
/
travis.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
#!/bin/bash
# shellcheck disable=SC1091
set -o errexit -o nounset -o pipefail
command -v shellcheck > /dev/null && shellcheck "$0"
#
# Travis helpers
#
if [[ "${TRAVIS_COMMIT:-}" != "" ]]; then
function fold_start() {
export CURRENT_FOLD_NAME="$1"
travis_fold start "$CURRENT_FOLD_NAME"
travis_time_start
}
function fold_end() {
travis_time_finish
travis_fold end "$CURRENT_FOLD_NAME"
}
else
function fold_start() { true; }
function fold_end() { true; }
fi
#
# Environment
#
TRAVIS_BUILD_VERSION=$(echo "${TRAVIS_COMMIT:-}" | cut -c 1-10)
BUILD_VERSION=${TRAVIS_BUILD_VERSION:-manual}
#
# Install
#
fold_start "yarn-install"
yarn install
fold_end
#
# Build
#
fold_start "yarn-build"
yarn build
yarn format
fold_end
fold_start "check-dirty"
# Ensure build step didn't modify source files to avoid unprettified repository state
SOURCE_CHANGES=$(git status --porcelain)
if [[ -n "$SOURCE_CHANGES" ]]; then
echo "Error: repository contains changes."
echo "Showing 'git status' and 'git diff' for debugging reasons now:"
git status
git diff
exit 1
fi
fold_end
#
# Lint
#
fold_start "lint"
yarn lint
fold_end
#
# Deploy
#
fold_start "docker-build"
docker build -t "iov1/ethereum-deployment:${BUILD_VERSION}" .
fold_end
fold_start "dockerhub-upload"
if [[ "${TRAVIS_NODE_VERSION:-}" == "10" && "${TRAVIS_OS_NAME:-}" == "linux" ]]; then
# only run in one job of the build matrix
if [[ "$TRAVIS_BRANCH" == "master" ]] && [[ "$TRAVIS_TAG" == "" ]] && [[ "$TRAVIS_PULL_REQUEST_BRANCH" == "" ]]; then
docker login -u "$DOCKER_USERNAME" -p "$DOCKER_PASSWORD"
docker tag "iov1/ethereum-deployment:${BUILD_VERSION}" "iov1/ethereum-deployment:latest"
docker push "iov1/ethereum-deployment:latest"
docker logout
fi
if [[ "$TRAVIS_TAG" != "" ]]; then
docker login -u "$DOCKER_USERNAME" -p "$DOCKER_PASSWORD"
docker tag "iov1/ethereum-deployment:${BUILD_VERSION}" "iov1/ethereum-deployment:$TRAVIS_TAG"
docker push "iov1/ethereum-deployment:$TRAVIS_TAG"
docker logout
fi
fi
fold_end