-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·72 lines (56 loc) · 1.42 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/usr/bin/env bash
set -ex
function build_tag () {
# Clean build
BUILD_PATH="${CWD}/build/$1"
rm -rf "${BUILD_PATH}"
mkdir -p "${BUILD_PATH}"
git fetch --all --prune
git fetch --tags
git checkout -- .
git clean -d --force -x
git checkout "${1}"
# Convert redirects to JSON file so they can be evaluated during site build
if [[ -f "${WEBSITE_PATH}/redirects.js" ]]; then
eval "${CWD}/tools/redirects-to-json.js ${WEBSITE_PATH}/redirects.js" > "${WEBSITE_PATH}/redirects.json"
fi
cd "${WEBSITE_PATH}"
# If package.json is not present
if [[ ! -f "./package.json" ]]; then
# Remove build directory and skip this release
rmdir "${BUILD_PATH}"
return
fi
npm ci
# Build website
npm run static
rm Rakefile || true
ln -s "${CWD}/Rakefile" . || true
# Build
rake
mv Nomad.tgz "${BUILD_PATH}"
}
# Read parameters
TAG=$1
if [ -z "$TAG" ]; then
echo '"TAG" must be specified'
exit 1
fi
# Paths
CWD=$(pwd)
NOMAD_PATH="${CWD}/nomad"
WEBSITE_PATH="${NOMAD_PATH}/website"
# Checkout and clean
git clone "https://github.com/hashicorp/nomad.git" || true
cd "${NOMAD_PATH}"
if [[ $TAG == "all" ]]; then
# List tags for Nomad 0.10.x - 1.x
declare -a TAGS
mapfile -t TAGS < <(git tag --list 'v0.1[0-2].*' 'v1.*')
for t in "${TAGS[@]}"
do
build_tag "$t"
done
else
build_tag "$TAG"
fi