+# STAGING_BUILD (below) may be unset
+set -e +u -x -o pipefail
+rm -fr "$TARDIR"
+
+if [ -n "$STAGING_BUILD" ]
+then
+ # Remove the "-SNAPSHOT" from the version for a staging build
+ VERSION=$(echo "$VERSION" | sed 's/-SNAPSHOT//')
+else
+ # Make sure the version has the "-SNAPSHOT" on the end for other builds
+ [[ ! "$VERSION" =~ -SNAPSHOT$ ]] && VERSION="${VERSION}-SNAPSHOT"
+fi
+
+# STAGING_BUILD not used past this point
+set -u