Revert "Tagging 1.14.0-b1"

This reverts commit 78ce40093ac008fd6d169ab83d2d5961f91f6e31.

Change-Id: I8482f550c30f75d65333f6be9c9115a930abc56f
diff --git a/tools/build/bazel/variables.bzl b/tools/build/bazel/variables.bzl
index cf611e3..7c32f8a 100644
--- a/tools/build/bazel/variables.bzl
+++ b/tools/build/bazel/variables.bzl
@@ -1,6 +1,6 @@
 ONOS_ORIGIN = "ONOS Community"
 ONOS_GROUP_ID = "org.onosproject"
-ONOS_VERSION = "1.14.0-b1"
+ONOS_VERSION = "1.14.0-SNAPSHOT"
 DEFAULT_APP_CATEGORY = "Utility"
 ONOS_ARTIFACT_BASE = "onos-"
 APP_PREFIX = ONOS_GROUP_ID + "."
diff --git a/tools/build/conf/pom.xml b/tools/build/conf/pom.xml
index 423f477..aa60ecf 100644
--- a/tools/build/conf/pom.xml
+++ b/tools/build/conf/pom.xml
@@ -27,7 +27,7 @@
 
     <groupId>org.onosproject</groupId>
     <artifactId>onos-build-conf</artifactId>
-    <version>1.14.0-b1</version>
+    <version>1.14.0-SNAPSHOT</version>
     <description>Various ONOS build settings</description>
 
     <properties>
diff --git a/tools/build/envDefaults b/tools/build/envDefaults
index 726cb83..d76bb52 100644
--- a/tools/build/envDefaults
+++ b/tools/build/envDefaults
@@ -18,8 +18,8 @@
 export BUILD_NUMBER=${BUILD_NUMBER:-$(id -un)}
 
 # ONOS Version and onos.tar.gz staging environment
-export ONOS_POM_VERSION="1.14.0-b1"
-export ONOS_VERSION=${ONOS_VERSION:-1.14.0-b1.$BUILD_NUMBER}
+export ONOS_POM_VERSION="1.14.0-SNAPSHOT"
+export ONOS_VERSION=${ONOS_VERSION:-1.14.0.$BUILD_NUMBER}
 
 # ONOS production bits (onos.tar.gz, onos.zip, onos.deb, onos.rpm) staging environment
 export ONOS_BITS=onos-${ONOS_VERSION%~*}
diff --git a/tools/build/onos-build-and-upload b/tools/build/onos-build-and-upload
index c7044c7..97657c9 100755
--- a/tools/build/onos-build-and-upload
+++ b/tools/build/onos-build-and-upload
@@ -20,6 +20,9 @@
     # upload docs
     onos-upload-docs ${WIKI_USER}
 
+    # upload release bits
+    onos-upload-bits
+
     # spot check that uploaded artifacts are correct
     check-uploaded-maven-artifacts  $VERSION $ONOS_ROOT https://oss.sonatype.org/content/groups/staging
 
@@ -30,5 +33,5 @@
     git push origin ${BRANCH}
 
     # Push tag for this build to git
-    #git push origin ${VERSION}
+    git push origin ${VERSION}
 fi
diff --git a/tools/build/onos-build-release b/tools/build/onos-build-release
index 38d8fd6..b45f7e6 100755
--- a/tools/build/onos-build-release
+++ b/tools/build/onos-build-release
@@ -28,7 +28,7 @@
 fi
 
 # Check that environment setup is correct
-# onos-release-prerequisites ${DRY_RUN}
+onos-release-prerequisites ${DRY_RUN}
 
 if [ ${IS_DRY_RUN} -eq 0 ]; then
     # Block commits to Gerrit
diff --git a/tools/build/onos-change-version b/tools/build/onos-change-version
index 89c14b9..9477e0f 100755
--- a/tools/build/onos-change-version
+++ b/tools/build/onos-change-version
@@ -16,7 +16,7 @@
 cd $ONOS_ROOT
 
 # Augment the version of the main pom and the modules nested underneath.
-#mvn -B versions:set -DnewVersion=$NEW_VERSION versions:commit
+mvn -B versions:set -DnewVersion=$NEW_VERSION versions:commit
 mvn -B -f lib/pom.xml versions:set -DnewVersion=$NEW_VERSION versions:commit
 sed -i".VERBACK" -E "1,/<version>/s/<version>[^<]*</<version>$NEW_VERSION</g" pom.xml
 
@@ -52,8 +52,4 @@
 sed -i".VERBACK" -E "s/ONOS_VERSION.*/ONOS_VERSION = '$NEW_VERSION'/" onos.defs
 sed -i".VERBACK" -E "s/ONOS_VERSION=.*/ONOS_VERSION='$NEW_VERSION'/" tools/build/onos-prepare-sonar
 
-# Version the bazel artifacts
-sed -i".VERBACK" -E "s/ONOS_VERSION.*/ONOS_VERSION = \"$NEW_VERSION\"/" tools/build/bazel/variables.bzl
-sed -i".VERBACK" -E "s/ONOS_VERSION.*/ONOS_VERSION = \"$NEW_VERSION\"/" WORKSPACE
-
 find . -name "*.VERBACK" | xargs rm -f
diff --git a/tools/build/onos-prepare-release b/tools/build/onos-prepare-release
index 476e984..9869ac3 100755
--- a/tools/build/onos-prepare-release
+++ b/tools/build/onos-prepare-release
@@ -31,17 +31,14 @@
 git tag -l | grep -q "$ONOS_VERSION\$" &&
   { echo "ERROR: Version already exists"; exit -1; }
 
-cp -R $ONOS_ROOT/tools/build/* $DIR/tools/build/
-cp $ONOS_ROOT/tools/test/bin/onos-archetypes-test $DIR/tools/test/bin/
+# Copy local buck configuration to new tree
+cp $ONOS_ROOT/.buckconfig.local $DIR/
 
 export ONOS_ROOT=$DIR
 # This is a hack to remove symlinks from the ONOS_ROOT path. To be removed when
 # the protobuf buck rules can handle symlinks
 ONOS_ROOT=$(pushd $ONOS_ROOT >/dev/null && pwd -P && popd >/dev/null)
 . $ONOS_ROOT/tools/build/envDefaults
-
-echo "stay away!" >buck-out
-
 exec bash $COMMAND
 
-
+# TODO on exit, print "leaving directory"
diff --git a/tools/build/onos-prepare-sonar b/tools/build/onos-prepare-sonar
index 47603bd..8caac59 100755
--- a/tools/build/onos-prepare-sonar
+++ b/tools/build/onos-prepare-sonar
@@ -12,7 +12,7 @@
 from subprocess import call, check_call, check_output
 
 # FIXME pull the version from the Buck version file
-ONOS_VERSION='1.14.0-b1'
+ONOS_VERSION='1.14.0-SNAPSHOT'
 
 # SonarQube property file name and template
 FILE_NAME = 'sonar-project.properties'
diff --git a/tools/build/onos-release b/tools/build/onos-release
index ae638fa..83d4506 100755
--- a/tools/build/onos-release
+++ b/tools/build/onos-release
@@ -22,6 +22,8 @@
 
 cd $ONOS_ROOT
 
+# TODO: Create a new branch for this activity?
+
 # Change the version
 onos-change-version $NEW_VERSION
 export ONOS_VERSION=$NEW_VERSION
@@ -30,29 +32,31 @@
 onos-validate-change-version
 
 # Build ONOS & deploy to staging repo using the release profile.
-bazel build onos
-
-# Build ONOS docs
-bazel build //docs:internal //docs:external
+onos-buck build onos
 
 if [ $dryRun -eq 0 ]; then
-    publish_url="oss.sonatype.org"
+    time onos-buck-publish
 else
-    publish_url=""
+    time onos-buck-publish-local
 fi
 
-# Create artifact catalog
-onos-publish-catalog publishing-catalog
+# Build ONOS docs
+onos-buck build //docs:internal //docs:external
 
-# publish artifacts
-onos-upload-artifacts.py publishing-catalog ${publish_url}
+# Package test tar.gz
+onos-buck build //:onos-test
+
+# Package admin tar.gz
+onos-buck build //:onos-admin
 
 # Build ONOS archetypes & deploy to staging repo using the release profile.
 # Note that release of the staging repository is a separate manual step.
 if [ $dryRun -eq 0 ]; then
+    export MVN_CLI_OPTS=-Pstaging
     pushd tools/package/archetypes/
-    mvn -B -Pstaging clean install && onos-archetypes-test -Pstaging && mvn -Pstaging -Prelease clean deploy
+    mvn -B -Pstaging clean install && onos-archetypes-test && mvn -Pstaging -Prelease clean deploy
     popd
+    unset MVN_CLI_OPTS
 else
     pushd tools/package/archetypes/
     mvn -B clean install && onos-archetypes-test
@@ -64,3 +68,5 @@
     git commit -a -m"Tagging $NEW_VERSION"
     git tag -sm"Tagging $NEW_VERSION" $NEW_VERSION #signed tag
 fi
+
+# TODO: push?
diff --git a/tools/build/onos-release-prerequisites b/tools/build/onos-release-prerequisites
index c25d829..f3d2b6b 100755
--- a/tools/build/onos-release-prerequisites
+++ b/tools/build/onos-release-prerequisites
@@ -100,6 +100,19 @@
     echo "OK"
 }
 
+# Test access to EC2
+function testEC2Access {
+    aux=$(mktemp)
+    trap "cat $aux; rm -f $aux; echo 'FAILED'" ERR
+    printf "Checking EC2 access... "
+    : "${AWS_ACCESS_KEY_ID:?AWS_ACCESS_KEY_ID must be set}"
+    : "${AWS_SECRET_ACCESS_KEY:?AWS_SECRET_ACCESS_KEY must be set}"
+
+    uploadToS3.py -v 1>$aux 2>&1
+    rm -f $aux
+    echo "OK"
+}
+
 # Sonatype account must be created & ~/.m2/settings.xml must be configured
 # Test by "releasing" a fake project setup for that purpose to validate access.
 function testSonatypeAccessMvn {
@@ -142,12 +155,40 @@
     echo "OK"
 }
 
+# .buckconfig.local must exist and the sonatype credentials must be set up
+function testBuckconfigLocal() {
+    printf "Checking local buck config..."
+    if [ ! -f $ONOS_ROOT/.buckconfig.local ]; then
+        echo ".buckconfig.local not found"
+        return 1
+    fi
+
+    trap "echo [publish] must be specified" ERR
+    grep -q "^\[publish\]" $ONOS_ROOT/.buckconfig.local
+
+    trap "echo maven_url must be specified" ERR
+    grep -q "maven_url" $ONOS_ROOT/.buckconfig.local
+
+    trap "echo maven_user must be specified" ERR
+    grep -q "maven_user" $ONOS_ROOT/.buckconfig.local
+
+    trap "echo maven_password must be specified" ERR
+    grep -q "maven_password" $ONOS_ROOT/.buckconfig.local
+
+    trap "echo pgp_keyring must be specified" ERR
+    grep -q "pgp_keyring" $ONOS_ROOT/.buckconfig.local
+
+    echo "OK"
+}
+
+testBuckconfigLocal
 testToolchain
 testSnapshotDependencies
 testGerritAccess
 
 if [ ${dryRun} -eq 0 ]; then
     testWikiAccess
+    testEC2Access
     testSonatypeAccessMvn
     testSonatypeAccessRest
 fi
diff --git a/tools/build/onos-upload-artifacts.py b/tools/build/onos-upload-artifacts.py
index 074c14d..0cd6c3e 100755
--- a/tools/build/onos-upload-artifacts.py
+++ b/tools/build/onos-upload-artifacts.py
@@ -20,7 +20,6 @@
 import hashlib
 import requests, os
 import xml.etree.ElementTree, shutil
-import time
 
 SONATYPE_USER=os.environ.get("SONATYPE_USER")
 SONATYPE_PASSWORD=os.environ.get("SONATYPE_PASSWORD")
@@ -43,8 +42,6 @@
 </promoteRequest>
 '''
 
-CLOSE_RETRY_ATTEMPTS = 12 * 2
-
 def hashlib_compute(hash, input_file, output_file):
     with open(input_file, 'rb') as f:
         for block in iter(lambda: f.read(100000), b''):
@@ -109,31 +106,6 @@
     r = requests.post(url, close_request, headers=headers, auth=(SONATYPE_USER, SONATYPE_PASSWORD))
 
 
-def wait_for_staging_repo(description, repo_id):
-    base_url = "https://" + destination_repo_url + "/service/local/staging/profiles" + "/" + SONATYPE_PROFILE
-    if repo_id is None:
-        return
-    close_request = CLOSE_REPO_REQUEST_TEMPLATE.replace("%(description)", description).replace("%(repo_id)", repo_id)
-    url = base_url + "/finish"
-    headers = {'Content-Type': 'application/xml'}
-    repo_query_url = "https://oss.sonatype.org/service/local/staging/repository/" + repo_id
-
-    attempt = 1
-    print ("waiting for repo to close...")
-    while True:
-        r = requests.get(repo_query_url, close_request, headers=headers, auth=(SONATYPE_USER, SONATYPE_PASSWORD))
-        root = xml.etree.ElementTree.fromstring(r.text)
-        transitioning = root.find("transitioning").text
-        if transitioning != "true":
-            break
-        if attempt == CLOSE_RETRY_ATTEMPTS:
-            print ("Unable to close repo")
-            sys.exit(1)
-        attempt = attempt + 1
-        time.sleep(5)
-    print ("Repo closed successfully")
-
-
 def stage_file(file, repo_id, dest):
     filename_in_repo = os.path.dirname(dest) + "/" + os.path.basename(file)
     if destination_repo_url is not None:
@@ -216,5 +188,4 @@
         dest = s[1]
         upload_file(src, dest)
     close_staging_repo(repo_id=repo_id, description=description)
-    wait_for_staging_repo(repo_id=repo_id, description=description)
     shutil.rmtree(tempdir)