Only modify the default doc set when a new release is made
Change-Id: I68fe73d3a8e39c55bb1b3d390cbdcae66c4ff1c5
diff --git a/tools/build/onos-upload-docs b/tools/build/onos-upload-docs
index 79986b6..1dc750a 100755
--- a/tools/build/onos-upload-docs
+++ b/tools/build/onos-upload-docs
@@ -13,6 +13,24 @@
docs=$(onos-buck build //docs:external --show-output 2>/dev/null | tail -1 | cut -d\ -f2)
+ONOS_VERSION_STRING=$ONOS_VERSION
+if echo $ONOS_VERSION_STRING | grep '-'; then
+ echo "ONOS version $ONOS_VERSION_STRING is a beta or RC. Skipping"
+ exit 0
+fi
+
+scp $remote:/var/www/api/index.html /tmp/index.html
+CURRENT_VERSION_STRING=`grep URL /tmp/index.html | sed "s%.*URL=/%%" | sed "s%/.*%%"`
+CURRENT_VERSION_SPLIT=(${CURRENT_VERSION_STRING//\./ })
+ONOS_VERSION_SPLIT=(${ONOS_VERSION_STRING//\./ })
+
+if (( ${ONOS_VERSION_SPLIT[1]} >= ${CURRENT_VERSION_SPLIT[1]} )); then
+ echo "Should replace current version $CURRENT_VERSION_STRING with new ONOS version $ONOS_VERSION_STRING"
+else
+ echo "Not replacing current version $CURRENT_VERSION_STRING with ONOS version $ONOS_VERSION_STRING"
+ exit 0
+fi
+
scp $docs $remote:/tmp/onos-apidocs-$ONOS_VERSION.tar.gz
ssh $remote "
mkdir -p /var/www/api/$ONOS_VERSION