Migrated release script to use Buck exclusively.

Change-Id: I04371594b68071488788c4ecbdb896a6306a2a14
diff --git a/tools/build/onos-package-test b/tools/build/onos-package-test
index 94d153d..1e23786 100755
--- a/tools/build/onos-package-test
+++ b/tools/build/onos-package-test
@@ -3,6 +3,9 @@
 # Packages ONOS test facilities into onos-test.tar.gz
 # -----------------------------------------------------------------------------
 
+echo "Use 'onos-buck build //:onos-test' instead"
+exit 1
+
 set -e
 
 [ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1
diff --git a/tools/build/onos-release b/tools/build/onos-release
index d4c1a80..774b0de 100755
--- a/tools/build/onos-release
+++ b/tools/build/onos-release
@@ -26,10 +26,14 @@
 onos-validate-change-version
 
 # Build ONOS & deploy to staging repo using the release profile.
-onos-build && onos-package --tar --zip && mvn -Prelease clean deploy -DskipTests
+onos-buck build onos
+time onos-buck-publish
 
 # Build ONOS docs
-onos-build-docs
+onos-buck build //docs:internal //docs:external
+
+# Package test tar.gz
+onos-buck build //:onos-test
 
 # Build ONOS archetypes & deploy to staging repo using the release profile.
 # Note that release of the staging repository is a separate manual step.
diff --git a/tools/build/onos-upload-bits b/tools/build/onos-upload-bits
index e3bb83c..c9f4c80 100755
--- a/tools/build/onos-upload-bits
+++ b/tools/build/onos-upload-bits
@@ -9,6 +9,20 @@
 . $ONOS_ROOT/tools/build/envDefaults
 
 #FIXME need to export s3Creds
-#TODO we could verify that ONOS_VERSION is set, and only upload that version
 
-onosUploadBits.py
+# Stage the onos tar in /tmp
+rm -f $ONOS_TAR
+cp $(onos-buck build onos --show-output | tail -1 | cut -d\  -f2) $ONOS_TAR
+
+# Repackage the onos tar
+pushd /tmp/
+tar xf onos-$ONOS_VERSION.tar.gz
+rm -f onos-$ONOS_VERSION.zip
+zip -r onos-$ONOS_VERSION.zip onos-$ONOS_VERSION/
+popd
+
+# Stage the test bits tar in /tmp
+rm -f $ONOS_TEST_TAR
+cp $(onos-buck build //:onos-test --show-output | tail -1 | cut -d\  -f2) $ONOS_TEST_TAR
+
+onosUploadBits.py $ONOS_VERSION
diff --git a/tools/build/onosUploadBits.py b/tools/build/onosUploadBits.py
index dc2f0a4..ae88b5c 100755
--- a/tools/build/onosUploadBits.py
+++ b/tools/build/onosUploadBits.py
@@ -14,11 +14,11 @@
 nightlyTag = 'NIGHTLY'
 bitsPath = '/tmp'
 
-prefix = 'onos-(\d+\.\d+\.\d+)'
+prefix = 'onos-(?:test-)?(\d+\.\d+\.\d+)'
 buildNum = '\.?([\w-]*)'
 ext = '\.(?:tar\.gz|zip|deb|noarch\.rpm)'
 
-def findBits( path ):
+def findBits( path, target_version=None ):
     for file in listdir( path ):
         filePath = join( path, file )
         if not isfile( filePath ):
@@ -28,6 +28,9 @@
         match = re.match( regex, file )
         if match:
             version = match.group(1)
+            if target_version is not None and version != target_version:
+                print 'Skipping %s...' % filePath
+                continue
             build = match.group(2)
             if build:
                 if 'NIGHTLY' in build or 'rc' in build:
@@ -37,4 +40,7 @@
                 uploadFile(filePath, dest='release/')
 
 if __name__ == '__main__':
-    findBits( '/tmp' )
+    import sys
+
+    version = sys.argv[1] if len(sys.argv) >= 2 else None
+    findBits( '/tmp', version )