Fix release-job.sh version var
[releng/global-jjb.git] / shell / release-job.sh
index 88b285c..96ccffb 100644 (file)
@@ -85,11 +85,21 @@ for release_file in $release_files; do
         cat "$PATCH_DIR"/taglist.log
     popd
 
+    # Verify allowed versions
+    # Allowed versions are "v#.#.#" or "#.#.#" aka SemVer
+    allowed_version_regex="^((v?)([0-9]+)\.([0-9]+)\.([0-9]+))$"
+    if [[ ! $VERSION =~ $allowed_version_regex ]]; then
+        echo "The version $VERSION is not a semantic valid version"
+        echo "Allowed versions are "v#.#.#" or "#.#.#" aka SemVer"
+        echo "See https://semver.org/ for more details on SemVer"
+        exit 1
+    fi
+
     git checkout "$(awk '{print $NF}' "$PATCH_DIR/taglist.log")"
     git fetch "$PATCH_DIR/$PROJECT.bundle"
     git merge --ff-only FETCH_HEAD
-    git tag -am "$PROJECT $VERSION" "v$VERSION"
-    sigul --batch -c "$SIGUL_CONFIG" sign-git-tag "$SIGUL_KEY" v"$VERSION" < "$SIGUL_PASSWORD"
+    git tag -am "$PROJECT $VERSION" "$VERSION"
+    sigul --batch -c "$SIGUL_CONFIG" sign-git-tag "$SIGUL_KEY" "$VERSION" < "$SIGUL_PASSWORD"
     echo "Showing latest signature for $PROJECT:"
     git log --show-signature -n1
 
@@ -97,7 +107,7 @@ for release_file in $release_files; do
     ########## Merge Part ##############
     if [[ "$JOB_NAME" =~ "merge" ]]; then
         echo "Running merge"
-        git push origin "v$VERSION"
+        git push origin "$VERSION"
         lftools nexus release --server "$NEXUS_URL" "$STAGING_REPO"
         if [ "${MAVEN_CENTRAL_URL}" == 'None' ]; then
             echo "No Maven central url specified, not pushing to maven central"