22
33# deploy artifacts to a directory, in preparation for GitHub deployment
44
5- # Default to success
5+ # Initialize globals used to track failures.
66exit_status=0
7+ declare -a failures # Array
78
89ROOT=$( dirname $( dirname $( realpath ${BASH_SOURCE[0]} ) ) )
910
@@ -14,58 +15,75 @@ function deploy_log() {
1415 echo " [DEPLOY] $( date) $* "
1516}
1617
18+ # Put "FAIL" between [DEPLOY] and date to make it easier to grep for failures (ie.., "\[DEPLOY\] FAIL" RE does the trick)
19+ # Don't put "FAIL" in [DEPLOY] so that we can first grep for [DEPLOY] and see all messages from this deploy.sh script.
20+ # Record failures but don't exit so that we can see which artifacts pass & fail.
21+ function deploy_fail() {
22+ echo " [DEPLOY] FAIL $( date) $* "
23+ failures+=(" $* " ) # Append to array
24+ exit_status=1
25+ }
26+
1727function deploy_mkdir() {
1828 [[ $# -ne 1 ]] && {
19- deploy_log " deploy_mkdir(): Passed $# args but it needs 1"
29+ deploy_fail " deploy_mkdir(): Passed $# args but it needs 1"
30+
31+ # Exit if args are wrong.
2032 exit 1
2133 }
2234
2335 local dst_dir=" $1 "
2436 mkdir -p $dst_dir || {
25- deploy_log " mkdir -p $dst_dir failed"
26- exit_status=1
37+ deploy_fail " mkdir -p $dst_dir failed"
2738 }
2839}
2940
3041function deploy_do() {
31- deploy_log " $@ "
42+ deploy_log
43+ deploy_log ' vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv'
44+ deploy_log " ./do $* "
45+ deploy_log ' ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^'
46+ deploy_log
3247 ./do " $@ " || {
33- deploy_log " ./do $* failed"
34- exit_status=1
48+ deploy_fail " ./do $* "
3549 }
3650}
3751
3852function deploy_cp_recursive() {
3953 [[ $# -ne 2 ]] && {
40- deploy_log " deploy_cp_recursive(): Passed $# args but it needs 2"
54+ deploy_fail " deploy_cp_recursive(): Passed $# args but it needs 2"
55+
56+ # Exit if args are wrong.
4157 exit 1
4258 }
4359
4460 local src_dir=" $1 "
4561 local dst_dir=" $2 "
4662
4763 cp -R ${src_dir} ${dst_dir} || {
48- deploy_log " cp -R ${src_dir} ${dst_dir} failed"
49- exit_status=1
64+ deploy_fail " cp -R ${src_dir} ${dst_dir} failed"
5065 }
5166}
5267
5368function deploy_cp() {
5469 [[ $# -ne 2 ]] && {
55- deploy_log " deploy_cp(): Passed $# args but it needs 2"
70+ deploy_fail " deploy_cp(): Passed $# args but it needs 2"
71+
72+ # Exit if args are wrong.
5673 exit 1
5774 }
5875
5976 local src_file=" $1 "
6077 local dst_dir=" $2 "
6178
6279 cp ${src_file} ${dst_dir} || {
63- deploy_log " cp ${src_file} ${dst_dir} failed"
64- exit_status=1
80+ deploy_fail " cp ${src_file} ${dst_dir} failed"
6581 }
6682}
6783
68- deploy_log " Starting"
84+ deploy_log ' ***************************************************************'
85+ deploy_log ' * DEPLOY STARTING *'
86+ deploy_log ' ***************************************************************'
6987
7088deploy_mkdir $DEPLOY_DIR
7189deploy_mkdir $DEPLOY_DIR /example_cfg
@@ -174,17 +192,17 @@ cat <<- EOF > $DEPLOY_DIR/index.html
174192 <li><a href="$PAGES_URL /isa_explorer/browser/ext_table.html">Extensions</a></li>
175193 <li><a href="$PAGES_URL /isa_explorer/browser/inst_table.html">Instructions</a></li>
176194 <li><a href="$PAGES_URL /isa_explorer/browser/csr_table.html">CSRs</a></li>
177- <li><a href="$PAGES_URL /isa_explorer.xlsx">Excel version (includes Extensions, Instructions, CSRs)</a></li>
195+ <li><a href="$PAGES_URL /isa_explorer/spreadsheet/isa_explorer .xlsx">Excel version (includes Extensions, Instructions, CSRs)</a></li>
178196 </ul>
179197
180198 <br/>
181199 <h3>Profile Releases</h3>
182200 <ul>
183- <li><a href="$PAGES_URL /pdfs/RVI20 .pdf">RVI20 Profile Release</a></li>
184- <li><a href="$PAGES_URL /pdfs/RVA20 .pdf">RVA20 Profile Release</a></li>
185- <li><a href="$PAGES_URL /pdfs/RVA22 .pdf">RVA22 Profile Release</a></li>
186- <li><a href="$PAGES_URL /pdfs/RVA23 .pdf">RVA23 Profile Release</a></li>
187- <li><a href="$PAGES_URL /pdfs/RVB23 .pdf">RVB23 Profile Release</a></li>
201+ <li><a href="$PAGES_URL /pdfs/RVI20ProfileRelease .pdf">RVI20 Profile Release</a></li>
202+ <li><a href="$PAGES_URL /pdfs/RVA20ProfileRelease .pdf">RVA20 Profile Release</a></li>
203+ <li><a href="$PAGES_URL /pdfs/RVA22ProfileRelease .pdf">RVA22 Profile Release</a></li>
204+ <li><a href="$PAGES_URL /pdfs/RVA23ProfileRelease .pdf">RVA23 Profile Release</a></li>
205+ <li><a href="$PAGES_URL /pdfs/RVB23ProfileRelease .pdf">RVB23 Profile Release</a></li>
188206 </ul>
189207
190208 <br/>
@@ -223,6 +241,26 @@ cat <<- EOF > $DEPLOY_DIR/index.html
223241</html>
224242EOF
225243
226- deploy_log " Complete"
244+ [[ $exit_status -eq 1 ]] && {
245+ deploy_log
246+ deploy_log ' ***************************************************************'
247+ deploy_log ' * DEPLOY FAILED *'
248+ deploy_log ' ***************************************************************'
249+ deploy_log
250+ deploy_log " LIST OF FAILURES:"
251+
252+ # Iterate through each failure array element.
253+ for f in " ${failures[@]} " ; do
254+ deploy_log " $f "
255+ done
256+ }
257+
258+ deploy_log
259+ deploy_log " Overall exit status is $exit_status "
260+ deploy_log
261+
262+ deploy_log ' ***************************************************************'
263+ deploy_log ' * DEPLOY COMPLETE *'
264+ deploy_log ' ***************************************************************'
227265
228266exit $exit_status
0 commit comments