Update release scripts to support major releases
[policy/parent.git] / integration / src / main / scripts / release / newReleaseSnapshots.sh
index 3e4ab2b..b80459b 100755 (executable)
@@ -4,7 +4,7 @@
 # ============LICENSE_START================================================
 # ONAP
 # =========================================================================
-# Copyright (C) 2022 Nordix Foundation.
+# Copyright (C) 2022-2023 Nordix Foundation.
 # =========================================================================
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
@@ -63,6 +63,7 @@ usage()
     echo "         -d data_file - the policy release data file to use, defaults to '$release_data_file'"
     echo "         -l location  - the location of the policy framework repos on the file system,"
     echo "                        defaults to '$repo_location'"
+    echo "         -m           - update snapshots for a major release, default is to update for a minor release"
     echo "         -i issue-id  - issue ID in the format POLICY-nnnn"
     echo ""
     echo " examples:"
@@ -72,7 +73,9 @@ usage()
     exit 255;
 }
 
-while getopts "hd:l:i:" opt
+major_release=false
+
+while getopts "hmd:l:i:" opt
 do
     case $opt in
     h)
@@ -87,6 +90,9 @@ do
     i)
         issue_id=$OPTARG
         ;;
+    m)
+        major_release=true
+        ;;
     \?)
         usage
         exit 1
@@ -159,9 +165,17 @@ do
     minor_version=$(echo "$latest_released_tag" | $SED -E 's/^[0-9]*\.([0-9]*)\.[0-9]*$/\1/')
     patch_version=$(echo "$next_release_version" | $SED -E 's/^[0-9]*\.[0-9]*\.([0-9]*)$/\1/')
     # shellcheck disable=SC2004
-    new_minor_version=$(($minor_version+1))
 
-    new_snapshot_tag="$major_version"."$new_minor_version".0-SNAPSHOT
+    if $major_release
+    then
+        new_major_version=$(($major_version+1))
+        new_minor_version=0
+    else
+        new_major_version=$major_version
+        new_minor_version=$(($minor_version+1))
+    fi
+
+    new_snapshot_tag="$new_major_version"."$new_minor_version".0-SNAPSHOT
 
     echo "updating snapshot version and references of repo $repo to $new_snapshot_tag . . ."
     mvn -f "$repo_location/$repo" \
@@ -172,6 +186,7 @@ do
 
     echo "set snapshot version of repo $repo in $repo_location/$repo/version.properties"
     $SED \
+        -e "s/major=$major_version/minor=$new_major_version/" \
         -e "s/minor=$minor_version/minor=$new_minor_version/" \
         -e "s/patch=$patch_version/patch=0/" \
         "$repo_location/$repo/version.properties" \
@@ -181,7 +196,7 @@ do
     updateRefs.sh -pcmoxs -d "$release_data_file" -l "$repo_location" -r "$repo"
 
     generateCommit.sh \
-        -l "$repo_location" \
+       -l "$repo_location" \
         -r "$repo" \
         -i "$issue_id" \
         -e "Set snapshot and/or references of $repo for new release" \