X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=integration%2Fsrc%2Frelease_scripts%2FbumpSnapshots.sh;h=d7d22df717de74ec6027afa31b728d384ccac2a5;hb=d7d9a664cb6d45b1019f8ac897feac512e5b37e8;hp=f8317e2a816b941122b684a0e5ac7f0c76081772;hpb=81c2c515c4c92cb77d7bc31eb2f2771ca2063216;p=policy%2Fparent.git diff --git a/integration/src/release_scripts/bumpSnapshots.sh b/integration/src/release_scripts/bumpSnapshots.sh index f8317e2a..d7d22df7 100755 --- a/integration/src/release_scripts/bumpSnapshots.sh +++ b/integration/src/release_scripts/bumpSnapshots.sh @@ -22,10 +22,18 @@ set -e -SCRIPT_NAME=`basename $0` +SCRIPT_NAME=$(basename "$0") repo_location="./" release_data_file="./pf_release_data.csv" +# Use the bash internal OSTYPE variable to check for MacOS +if [[ "$OSTYPE" == "darwin"* ]] +then + SED="gsed" +else + SED="sed" +fi + declare -a pf_repos=( "policy/parent" "policy/docker" @@ -130,11 +138,14 @@ fi for specified_repo in "${pf_repos[@]}" do - read repo \ + # shellcheck disable=SC2034 + # shellcheck disable=SC2046 + read -r repo \ latest_released_tag \ latest_snapshot_tag \ - changed_files docker_images \ - <<< $( grep $specified_repo $release_data_file | tr ',' ' ' ) + changed_files \ + docker_images \ + <<< $(grep "$specified_repo" "$release_data_file" | tr ',' ' ' ) if [ ! "$repo" = "$specified_repo" ] then @@ -146,30 +157,37 @@ do if [ "$latest_released_tag" = "$next_release_version" ] then - declare -i major_version=`echo $next_release_version | sed -E 's/^([0-9]*)\.[0-9]*\.[0-9]*$/\1/'` - declare -i minor_version=`echo $next_release_version | sed -E 's/^[0-9]*\.([0-9]*)\.[0-9]*$/\1/'` - declare -i patch_version=`echo $next_release_version | sed -E 's/^[0-9]*\.[0-9]*\.([0-9]*)$/\1/'` - declare -i new_patch_version=$(($patch_version+1)) + major_version=$(echo "$next_release_version" | $SED -E 's/^([0-9]*)\.[0-9]*\.[0-9]*$/\1/') + minor_version=$(echo "$next_release_version" | $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_patch_version=$(($patch_version+1)) new_snapshot_tag="$major_version"."$minor_version"."$new_patch_version"-SNAPSHOT - echo updating snapshot version and references of repo $repo to $new_snapshot_tag . . . - mvn -f $repo_location/$repo \ - -DnewVersion=$new_snapshot_tag versions:set \ + echo "updating snapshot version and references of repo $repo to $new_snapshot_tag . . ." + mvn -f "$repo_location/$repo" \ + "-DnewVersion=$new_snapshot_tag" versions:set \ versions:update-child-modules versions:commit temp_file=$(mktemp) - echo updating snapshot version of repo $repo in $repo_location/$repo/version.properties - sed -e "s/patch=$patch_version/patch=$new_patch_version/" $repo_location/$repo/version.properties > $temp_file - mv $temp_file $repo_location/$repo/version.properties + echo "updating snapshot version of repo $repo in $repo_location/$repo/version.properties" + $SED -e "s/patch=$patch_version/patch=$new_patch_version/" \ + "$repo_location/$repo/version.properties" > "$temp_file" + mv "$temp_file" "$repo_location/$repo/version.properties" fi - updateRefs.sh -pcmos -d $release_data_file -l $repo_location -r $repo - git -C $repo_location/$specified_repo status | grep '^[ \t]*modified:[ \t]*pom.xml' > /dev/null 2>&1 - references_updated=$? + updateRefs.sh -pcmos -d "$release_data_file" -l "$repo_location" -r "$repo" + + if [ "$(git -C "$repo_location/$specified_repo" status | grep '^[ \t]*modified:[ \t]*pom.xml' > /dev/null 2>&1)" = 0 ] + then + references_updated=0 + else + references_updated=1 + fi - if [ "$latest_released_tag" != "$next_release_version" ] && [ $references_updated -eq 0 ] + if [ "$latest_released_tag" != "$next_release_version" ] && [ $references_updated -ne 0 ] then continue fi @@ -177,9 +195,9 @@ do echo "generating commit to update snapshot version and/or references of repo $repo . . ." generateCommit.sh \ - -l $repo_location \ - -r $repo \ - -i $issue_id \ + -l "$repo_location" \ + -r "$repo" \ + -i "$issue_id" \ -e "Update snapshot and/or references of $repo to latest snapshots" \ -m "$repo updated to its latest own and reference snapshots"