blob: 5c311a3ec0822bb36b72194b252b71404ae9d472 [file] [log] [blame]
Thomas Vachuska683b31b2015-01-26 11:54:31 -08001#!/bin/bash
2# -----------------------------------------------------------------------------
3# Uploads ONOS Java API docs.
4# -----------------------------------------------------------------------------
5
Brian O'Connorf5d93632015-09-04 20:18:31 -07006set -e
7
Thomas Vachuska683b31b2015-01-26 11:54:31 -08008[ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1
9. $ONOS_ROOT/tools/build/envDefaults
10
Brian O'Connora3178722016-03-10 15:44:27 -080011user=${1:-${WIKI_USER:-$USER}}
Ray Milkey46b3e852017-09-05 19:41:15 -070012remote=$user@api.onosproject.org
Thomas Vachuska683b31b2015-01-26 11:54:31 -080013
Brian O'Connor1b6ae592016-10-25 00:45:00 -070014docs=$(onos-buck build //docs:external --show-output 2>/dev/null | tail -1 | cut -d\ -f2)
15
Ray Milkey75ee45e2018-01-19 14:08:20 -080016ONOS_VERSION_STRING=$ONOS_VERSION
17if echo $ONOS_VERSION_STRING | grep '-'; then
18 echo "ONOS version $ONOS_VERSION_STRING is a beta or RC. Skipping"
19 exit 0
20fi
21
22scp $remote:/var/www/api/index.html /tmp/index.html
23CURRENT_VERSION_STRING=`grep URL /tmp/index.html | sed "s%.*URL=/%%" | sed "s%/.*%%"`
24CURRENT_VERSION_SPLIT=(${CURRENT_VERSION_STRING//\./ })
25ONOS_VERSION_SPLIT=(${ONOS_VERSION_STRING//\./ })
26
27if (( ${ONOS_VERSION_SPLIT[1]} >= ${CURRENT_VERSION_SPLIT[1]} )); then
Ray Milkey859e0412018-03-27 13:58:08 -070028 replace="1"
Ray Milkey75ee45e2018-01-19 14:08:20 -080029 echo "Should replace current version $CURRENT_VERSION_STRING with new ONOS version $ONOS_VERSION_STRING"
30else
31 echo "Not replacing current version $CURRENT_VERSION_STRING with ONOS version $ONOS_VERSION_STRING"
Ray Milkey859e0412018-03-27 13:58:08 -070032 replace="0"
Ray Milkey75ee45e2018-01-19 14:08:20 -080033fi
34
Brian O'Connor1b6ae592016-10-25 00:45:00 -070035scp $docs $remote:/tmp/onos-apidocs-$ONOS_VERSION.tar.gz
Thomas Vachuska683b31b2015-01-26 11:54:31 -080036ssh $remote "
37 mkdir -p /var/www/api/$ONOS_VERSION
38 cd /var/www/api/$ONOS_VERSION
Brian O'Connor1b6ae592016-10-25 00:45:00 -070039 unzip /tmp/onos-apidocs-$ONOS_VERSION.tar.gz
40 #mv onos-apidocs-$ONOS_VERSION/* .
41 #rm -rf onos-apidocs-$ONOS_VERSION
Thomas Vachuska683b31b2015-01-26 11:54:31 -080042
Brian O'Connorc04e8762016-03-01 19:18:53 -080043 # bump /var/www/api/index.html
Ray Milkey859e0412018-03-27 13:58:08 -070044 if [ "$replace" == "1" ]; then
45 sed -i -E 's#/[^/]+/#/$ONOS_VERSION/#g' /var/www/api/index.html
46 fi
Thomas Vachuska683b31b2015-01-26 11:54:31 -080047"