Fix small bugs in release scripts
[policy/parent.git] / integration / src / main / scripts / release / updateRefs.sh
index 0f253f9..9e1231a 100755 (executable)
@@ -54,6 +54,7 @@ usage()
     echo "         -o           - update policy/drools-pdp references"
     echo "         -x           - update policy/apex-pdp references"
     echo "         -k           - update docker base images in Dockerfiles"
+    echo "         -f           - update release data in policy parent"
     echo "         -s           - update release references to snapshot references,"
     echo "                        if omitted, snapshot references are updated to release references"
     echo ""
@@ -75,8 +76,9 @@ update_drools_pdp=false
 update_apex_pdp=false
 update_snapshot=false
 update_docker=false
+update_file=false
 
-while getopts "hd:l:r:pcmoxks" opt
+while getopts "hd:l:r:pcmoxkfs" opt
 do
     case $opt in
     h)
@@ -109,6 +111,9 @@ do
     k)
         update_docker=true
         ;;
+    f)
+        update_file=true
+        ;;
     s)
         update_snapshot=true
         ;;
@@ -239,8 +244,8 @@ then
             major_version=$(echo "$parent_latest_released_tag" | $SED -E 's/^([0-9]*)\.[0-9]*\.[0-9]*$/\1/')
             minor_version=$(echo "$parent_latest_released_tag" | $SED -E 's/^[0-9]*\.([0-9]*)\.[0-9]*$/\1/')
             patch_version=$(echo "$parent_latest_released_tag" | $SED -E 's/^[0-9]*\.[0-9]*\.([0-9]*)$/\1/')
-            new_patch_version=$(("$patch_version"+1))
 
+            new_patch_version=$((patch_version+1))
             new_snapshot_tag="$major_version"."$minor_version"."$new_patch_version"-SNAPSHOT
 
             echo updating policy parent reference to "$new_snapshot_tag" on "$repo_location/$target_repo" . . .
@@ -396,13 +401,21 @@ fi
 
 if [ "$update_docker" = true ] && [ "$target_docker_images" != "" ]
 then
-    echo "updating docker base images to version $docker_latest_released_tag on repo $repo_location/$target_repo . . ."
-    find "$repo_location/$target_repo" \
-        -name '*Docker*'
-    find "$repo_location/$target_repo" \
-        -name '*Docker*' \
-        -exec $SED -r -i "s/^(FROM onap\/policy-j[d|r][k|e]-alpine:)[0-9]*.[0-9]*.[0-9]*$/\1$docker_latest_released_tag/" {} \;
-    result_code=$?
+    if [ "$update_snapshot" == true ]
+    then
+        echo "updating docker base images to version $docker_latest_snapshot_tag on repo $repo_location/$target_repo . . ."
+        find "$repo_location/$target_repo" \
+            -name '*Docker*' \
+            -exec $SED -r -i "s/^(FROM onap\/policy-j[d|r][k|e]-alpine:)[0-9]*.[0-9]*.[0-9].*$/\1$docker_latest_snapshot_tag/" {} \;
+        result_code=$?
+    else
+        echo "updating docker base images to version $docker_latest_released_tag on repo $repo_location/$target_repo . . ."
+        find "$repo_location/$target_repo" \
+            -name '*Docker*' \
+            -exec $SED -r -i "s/^(FROM onap\/policy-j[d|r][k|e]-alpine:)[0-9]*.[0-9]*.[0-9].*$/\1$docker_latest_released_tag/" {} \;
+        result_code=$?
+    fi
+
     if [[ "$result_code" -eq 0 ]]
     then
         echo "docker base images updated on $repo_location/$target_repo"
@@ -411,3 +424,16 @@ then
         exit 1
     fi
 fi
+
+if [ "$update_file" = true ]
+then
+    if [ ! "$target_repo" = "policy/parent" ]
+    then
+        echo "update of data file can only be done on the policy/parent repo"
+        exit 1
+    fi
+
+    echo "updating release data at $repo_location/$target_repo/integration/src/main/resources/release . . ."
+    cp "$release_data_file" "$repo_location/$target_repo"/integration/src/main/resources/release
+    echo "updated release data at $repo_location/$target_repo/integration/src/main/resources/release"
+fi