-
Notifications
You must be signed in to change notification settings - Fork 5
/
travis.script.sh
executable file
·65 lines (51 loc) · 1.71 KB
/
travis.script.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
#!/bin/bash
#exit script on any error
set -e
#Shell Colour constants for use in 'echo -e'
#e.g. echo -e "My message ${GREEN}with just this text in green${NC}"
# shellcheck disable=SC2034
{
RED='\033[1;31m'
GREEN='\033[1;32m'
YELLOW='\033[1;33m'
BLUE='\033[1;34m'
NC='\033[0m' # No Colour
}
create_file_hash() {
local -r file="$1"
local -r hash_file="${file}.sha256"
echo -e "Creating a SHA-256 hash for file ${GREEN}${file}${NC}"
sha256sum "${file}" > "${hash_file}"
echo -e "Created hash file ${GREEN}${hash_file}${NC}"
}
generate_file_hashes() {
for file in "${TRAVIS_BUILD_DIR}"/stroom-content-artifacts/*.zip; do
create_file_hash "${file}"
done
}
main() {
if [ -n "$TRAVIS_TAG" ]; then
#Tagged commit so use that as our version, e.g. v3.2.0
local -r VERSION="${TRAVIS_TAG}"
fi
#Dump all the travis env vars to the console for debugging
echo -e "TRAVIS_BUILD_DIR: [${GREEN}${TRAVIS_BUILD_DIR}${NC}]"
echo -e "TRAVIS_BUILD_NUMBER: [${GREEN}${TRAVIS_BUILD_NUMBER}${NC}]"
echo -e "TRAVIS_COMMIT: [${GREEN}${TRAVIS_COMMIT}${NC}]"
echo -e "TRAVIS_BRANCH: [${GREEN}${TRAVIS_BRANCH}${NC}]"
echo -e "TRAVIS_TAG: [${GREEN}${TRAVIS_TAG}${NC}]"
echo -e "TRAVIS_PULL_REQUEST: [${GREEN}${TRAVIS_PULL_REQUEST}${NC}]"
echo -e "TRAVIS_EVENT_TYPE: [${GREEN}${TRAVIS_EVENT_TYPE}${NC}]"
echo -e "VERSION: [${GREEN}${VERSION}${NC}]"
#Normal commit/PR/tag build
local extraBuildArgs=()
if [ -n "$TRAVIS_TAG" ]; then
extraBuildArgs+=( "${VERSION}" )
echo -e "extraBuildArgs: [${GREEN}${extraBuildArgs[*]}${NC}]"
fi
#Do the build
./stroom-content-builder/buildImportBundle.sh "${extraBuildArgs[@]}"
generate_file_hashes
}
main "$@"
exit 0