1
+ #! /bin/bash
2
+
3
+ # Exit on first error, print all commands.
4
+ set -ev
5
+ set -o pipefail
6
+
7
+ # Grab the parent (root) directory.
8
+ DIR=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) /.." && pwd ) "
9
+ date
10
+ ME=` basename " $0 " `
11
+
12
+ source ${DIR} /build.cfg
13
+
14
+ if [ " ${ABORT_BUILD} " = " true" ]; then
15
+ echo exiting early from ${ME}
16
+ exit ${ABORT_CODE}
17
+ fi
18
+
19
+ # Check that this is the right node.js version.
20
+ if [ " ${TRAVIS_NODE_VERSION} " != " " -a " ${TRAVIS_NODE_VERSION} " != " 6" ]; then
21
+ echo Not executing as not running primary node.js version.
22
+ exit 0
23
+ fi
24
+
25
+ # Check that this is not the system tests.
26
+ if [ " ${SYSTEST} " != " " ]; then
27
+ echo Not executing as running system tests.
28
+ exit 0
29
+ fi
30
+
31
+ # Check that this is the main repository.
32
+ if [[ " ${TRAVIS_REPO_SLUG} " != hyperledger* ]]; then
33
+ echo " Skipping deploy; wrong repository slug."
34
+ exit 0
35
+ fi
36
+
37
+ # are we building the docs?
38
+ if [ " ${DOCS} " != " " ]; then
39
+ if [ -z " ${TRAVIS_TAG} " ]; then
40
+ DOCS=" unstable"
41
+ else
42
+ DOCS=" full"
43
+ fi
44
+ ./.travis/deploy_docs.sh
45
+ exit 0
46
+ fi
47
+
48
+
49
+ # Set the GitHub deploy key we will use to publish.
50
+ set-up-ssh --key " $encrypted_c6d9af089ec4_key " \
51
+ --iv " $encrypted_c6d9af089ec4_iv " \
52
+ --path-encrypted-key " .travis/github_deploy_key.enc"
53
+
54
+ # Change from HTTPS to SSH.
55
+ ./.travis/fix_github_https_repo.sh
56
+
57
+ # Test the GitHub deploy key.
58
+ git ls-remote
59
+
60
+ # Log in to Docker Hub.
61
+ docker login -u=" ${DOCKER_USERNAME} " -p=" ${DOCKER_PASSWORD} "
62
+
63
+ # This is the list of Docker images to build.
64
+ export DOCKER_IMAGES=(vehicle-lifecycle-car-builder vehicle-lifecycle-manufacturing vehicle-lifecycle-vda)
65
+ export VERSION=($( node -e " console.log(require('${DIR} /package.json').version)" ) )
66
+
67
+ # Push the code to npm.
68
+ if [ -z " ${TRAVIS_TAG} " ]; then
69
+
70
+ npm run pkgstamp
71
+ for image in ${DOCKER_IMAGES} ; do
72
+
73
+ # Build the image and tag it with the version and unstable.
74
+ docker build --build-arg VERSION=${VERSION} -t hyperledger/${image} :${VERSION}${DIR} /packages/${image} /docker
75
+ docker tag hyperledger/${image} :${VERSION} hyperledger/${image} :unstable
76
+
77
+ # Push both the version and unstable.
78
+ docker push hyperledger/${image} :${VERSION}
79
+ docker push hyperledger/${image} :unstable
80
+
81
+ done
82
+
83
+ else
84
+
85
+ # Build, tag, and publish Docker images.
86
+ for image in ${DOCKER_IMAGES} ; do
87
+
88
+ # Build the image and tag it with the version and latest.
89
+ docker build --build-arg VERSION=${VERSION} -t hyperledger/${image} :${VERSION} ${DIR} /packages/${image} /docker
90
+ docker tag hyperledger/${image} :${VERSION} hyperledger/${image} :latest
91
+
92
+ # Push both the version and latest.
93
+ docker push hyperledger/${image} :${VERSION}
94
+ docker push hyperledger/${image} :latest
95
+
96
+ done
97
+
98
+ # Configure the Git repository and clean any untracked and unignored build files.
99
+ git config user.name " ${GH_USER_NAME} "
100
+ git config user.email " ${GH_USER_EMAIL} "
101
+ git checkout -b master
102
+ git reset --hard
103
+ git clean -d -f
104
+
105
+ # Bump the version number.
106
+ npm run pkgbump
107
+ export NEW_VERSION=$( node -e " console.log(require('${DIR} /package.json').version)" )
108
+
109
+ # Add the version number changes and push them to Git.
110
+ git add .
111
+ git commit -m " Automatic version bump to ${NEW_VERSION} "
112
+ git push origin master
113
+
114
+ fi
115
+ date
0 commit comments