forked from openshift-kni/baremetal-deploy
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.sh
executable file
·133 lines (109 loc) · 3.12 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#!/bin/bash
# Builds documentation for each release in both HTML and PDF versions
# Space separated version list to build
RELEASES="4.6 4.5 4.4 4.3"
# Devel releases for static documents and devel docs
DEVRELEASE="4.7"
# STATIC Release
STATICRELEASE="${DEVRELEASE}"
# Versioned documents
DOCS=(
'Deployment'
'Troubleshooting'
)
# Documents using latest
STATIC=(
'Ansible Playbook Install'
'Ansible Playbook Disconnected Install'
)
DEV=(
'Deployment'
'Troubleshooting'
)
# Get latest version for 'static' documents
LATEST=$(echo ${RELEASES} | tr " " "\n" | sort -V -r | head -1)
build_for_release() {
doc="${1}"
release="${2}"
extraargs="${3}"
echo "Building documentation doc ${doc} for release ${release}"
basedir=$(dirname $(readlink "documentation/${doc}.adoc"))
basefile=$(basename $(readlink "documentation/${doc}.adoc"))
# Build the documentation
asciidoctor -a release="${release}" -a toc=left ${extraargs} -b xhtml5 -d book -B "documentation/${basedir}/" "documentation/${basedir}/${basefile}" -o "${doc}.html" -D "../../website/${release}" 2>&1 | grep -v 'Try: gem'
myrc=${?}
# Build the documentation PDF
asciidoctor-pdf -a release="${release}" -a toc=left ${extraargs} -d book -B "documentation/${basedir}/" "documentation/${basedir}/${basefile}" -o "${doc}.pdf" -D "../../website/${release}" 2>&1 | grep -v 'Try: gem'
}
RC=0
# Build all releases
for release in ${RELEASES}; do
for doc in "${DOCS[@]}"; do
build_for_release "${doc}" "${release}"
done
done
# Build latest for static
for release in ${STATICRELEASE}; do
for doc in "${STATIC[@]}"; do
build_for_release "${doc}" "${release}"
done
done
# Build latest for DEVEL
for release in ${DEVRELEASE}; do
for doc in "${DEV[@]}"; do
build_for_release "${doc}" "${release}" "-a watermark=True"
done
done
# Build JSON of generated documentation pages
TARGET="website/_data"
mkdir -p ${TARGET}
# Build HTML page for all generated docs
# Empty file before starting for VERSIONED
>${TARGET}/releases.yml
for release in ${RELEASES}; do
for doc in "${DOCS[@]}"; do
echo """
${doc}-${release}:
name: ${doc}
release: ${release}
folder: ${release}/${doc}
""" >>${TARGET}/releases.yml
done
done
# Empty file before starting for VERSIONED DOCS
>${TARGET}/versioned.yml
for doc in "${DOCS[@]}"; do
echo """
${doc}:
name: ${doc}
""" >>${TARGET}/versioned.yml
done
# Empty file before starting for DEVEL preview
>${TARGET}/devprev.yml
for release in ${DEVRELEASE}; do
for doc in "${DEV[@]}"; do
echo """
${doc}-${release}:
name: ${doc}
release: ${release}
folder: ${release}/${doc}
""" >>${TARGET}/devprev.yml
done
done
# Empty file before starting for STATIC
>${TARGET}/static.yml
for release in ${STATICRELEASE}; do
for doc in "${STATIC[@]}"; do
echo """
${doc}-${release}:
name: ${doc}
release: ${release}
folder: latest/${doc}
""" >>${TARGET}/static.yml
done
done
rm -f website/latest
ln -s ${release} website/latest
# TODO: CHECK why RC != 0 with no errors website (despite of gem)
RC=0
exit ${RC}