liamfallon | 81c2c51 | 2021-12-16 12:56:37 +0000 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | # |
| 4 | # ============LICENSE_START================================================ |
| 5 | # ONAP |
| 6 | # ========================================================================= |
| 7 | # Copyright (C) 2021-2022 Nordix Foundation. |
| 8 | # ========================================================================= |
| 9 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 10 | # you may not use this file except in compliance with the License. |
| 11 | # You may obtain a copy of the License at |
| 12 | # |
| 13 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 14 | # |
| 15 | # Unless required by applicable law or agreed to in writing, software |
| 16 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 18 | # See the License for the specific language governing permissions and |
| 19 | # limitations under the License. |
| 20 | # ============LICENSE_END================================================== |
| 21 | # |
| 22 | |
| 23 | set -e |
| 24 | |
liamfallon | d7d9a66 | 2022-03-01 21:01:03 +0000 | [diff] [blame] | 25 | SCRIPT_NAME=$(basename "$0") |
liamfallon | 81c2c51 | 2021-12-16 12:56:37 +0000 | [diff] [blame] | 26 | repo_location="./" |
| 27 | release_data_file="./pf_release_data.csv" |
| 28 | |
liamfallon | b76315a | 2022-01-12 13:24:54 +0000 | [diff] [blame] | 29 | # Use the bash internal OSTYPE variable to check for MacOS |
| 30 | if [[ "$OSTYPE" == "darwin"* ]] |
| 31 | then |
| 32 | SED="gsed" |
| 33 | else |
| 34 | SED="sed" |
| 35 | fi |
| 36 | |
liamfallon | 81c2c51 | 2021-12-16 12:56:37 +0000 | [diff] [blame] | 37 | usage() |
| 38 | { |
| 39 | echo "" |
| 40 | echo "$SCRIPT_NAME - updates the inter-repo references in Policy Framework POM files" |
| 41 | echo "" |
| 42 | echo " usage: $SCRIPT_NAME [-options]" |
| 43 | echo "" |
| 44 | echo " options" |
| 45 | echo " -h - this help message" |
| 46 | echo " -d data_file - the policy release data file to use, generated by the 'getReleaseData.sh' script," |
| 47 | echo " defaults to '$release_data_file'" |
| 48 | echo " -l location - the location of the policy framework repos on the file system," |
| 49 | echo " defaults to '$repo_location'" |
| 50 | echo " -r repo - the policy repo to update" |
| 51 | echo " -p - update policy/parent references" |
| 52 | echo " -c - update policy/common references" |
| 53 | echo " -m - update policy/model references" |
| 54 | echo " -o - update policy/drools-pdp references" |
liamfallon | 4d071bf | 2022-03-16 14:27:21 +0000 | [diff] [blame] | 55 | echo " -x - update policy/apex-pdp references" |
liamfallon | 81c2c51 | 2021-12-16 12:56:37 +0000 | [diff] [blame] | 56 | echo " -k - update docker base images in Dockerfiles" |
liamfallon | 5555653 | 2022-07-13 11:40:56 +0100 | [diff] [blame] | 57 | echo " -f - update release data in policy parent" |
liamfallon | 81c2c51 | 2021-12-16 12:56:37 +0000 | [diff] [blame] | 58 | echo " -s - update release references to snapshot references," |
| 59 | echo " if omitted, snapshot references are updated to release references" |
| 60 | echo "" |
| 61 | echo " examples:" |
| 62 | echo " $SCRIPT_NAME -pcm -r policy/pap" |
| 63 | echo " update the parent, common, and models references of policy/pap" |
| 64 | echo " to the current released version" |
| 65 | echo "" |
| 66 | echo " $SCRIPT_NAME -c -m -s -r policy/api" |
| 67 | echo " update the common and models references of policy/api" |
| 68 | echo " to the current snapshot version" |
| 69 | exit 255; |
| 70 | } |
| 71 | |
| 72 | update_parent=false |
| 73 | update_common=false |
| 74 | update_models=false |
| 75 | update_drools_pdp=false |
liamfallon | 4d071bf | 2022-03-16 14:27:21 +0000 | [diff] [blame] | 76 | update_apex_pdp=false |
liamfallon | 81c2c51 | 2021-12-16 12:56:37 +0000 | [diff] [blame] | 77 | update_snapshot=false |
| 78 | update_docker=false |
liamfallon | 5555653 | 2022-07-13 11:40:56 +0100 | [diff] [blame] | 79 | update_file=false |
liamfallon | 81c2c51 | 2021-12-16 12:56:37 +0000 | [diff] [blame] | 80 | |
liamfallon | 5555653 | 2022-07-13 11:40:56 +0100 | [diff] [blame] | 81 | while getopts "hd:l:r:pcmoxkfs" opt |
liamfallon | 81c2c51 | 2021-12-16 12:56:37 +0000 | [diff] [blame] | 82 | do |
| 83 | case $opt in |
| 84 | h) |
| 85 | usage |
| 86 | ;; |
| 87 | d) |
| 88 | release_data_file=$OPTARG |
| 89 | ;; |
| 90 | l) |
| 91 | repo_location=$OPTARG |
| 92 | ;; |
| 93 | r) |
| 94 | specified_repo=$OPTARG |
| 95 | ;; |
| 96 | p) |
| 97 | update_parent=true |
| 98 | ;; |
| 99 | c) |
| 100 | update_common=true |
| 101 | ;; |
| 102 | m) |
| 103 | update_models=true |
| 104 | ;; |
| 105 | o) |
| 106 | update_drools_pdp=true |
| 107 | ;; |
liamfallon | 4d071bf | 2022-03-16 14:27:21 +0000 | [diff] [blame] | 108 | x) |
| 109 | update_apex_pdp=true |
| 110 | ;; |
liamfallon | 81c2c51 | 2021-12-16 12:56:37 +0000 | [diff] [blame] | 111 | k) |
| 112 | update_docker=true |
| 113 | ;; |
liamfallon | 5555653 | 2022-07-13 11:40:56 +0100 | [diff] [blame] | 114 | f) |
| 115 | update_file=true |
| 116 | ;; |
liamfallon | 81c2c51 | 2021-12-16 12:56:37 +0000 | [diff] [blame] | 117 | s) |
| 118 | update_snapshot=true |
| 119 | ;; |
| 120 | \?) |
| 121 | usage |
| 122 | exit 1 |
| 123 | ;; |
| 124 | esac |
| 125 | done |
| 126 | |
| 127 | if [ $OPTIND -eq 1 ] |
| 128 | then |
| 129 | echo "no arguments were specified" |
| 130 | usage |
| 131 | fi |
| 132 | |
| 133 | if [[ -z "$repo_location" ]] |
| 134 | then |
| 135 | echo "policy repo location not specified on -l flag" |
| 136 | exit 1 |
| 137 | fi |
| 138 | |
| 139 | if ! [ -d "$repo_location" ] |
| 140 | then |
| 141 | echo "policy repo location '$repo_location' not found" |
| 142 | exit 1 |
| 143 | fi |
| 144 | |
| 145 | if [[ -z "$release_data_file" ]] |
| 146 | then |
| 147 | echo "policy release data file not specified on -d flag" |
| 148 | exit 1 |
| 149 | fi |
| 150 | |
| 151 | if ! [ -f "$release_data_file" ] |
| 152 | then |
| 153 | echo "policy release data file '$release_data_file' not found" |
| 154 | exit 1 |
| 155 | fi |
| 156 | |
| 157 | if [ -z "$specified_repo" ] |
| 158 | then |
| 159 | echo "repo not specified on -r flag" |
| 160 | exit 1 |
| 161 | fi |
| 162 | |
liamfallon | d7d9a66 | 2022-03-01 21:01:03 +0000 | [diff] [blame] | 163 | # shellcheck disable=SC2034 |
| 164 | # shellcheck disable=SC2046 |
| 165 | read -r parent_repo \ |
liamfallon | 81c2c51 | 2021-12-16 12:56:37 +0000 | [diff] [blame] | 166 | parent_latest_released_tag \ |
| 167 | parent_latest_snapshot_tag \ |
| 168 | parent_changed_files \ |
| 169 | parent_docker_images \ |
liamfallon | d7d9a66 | 2022-03-01 21:01:03 +0000 | [diff] [blame] | 170 | <<< $(grep policy/parent "$release_data_file" | tr ',' ' ' ) |
liamfallon | 81c2c51 | 2021-12-16 12:56:37 +0000 | [diff] [blame] | 171 | |
liamfallon | d7d9a66 | 2022-03-01 21:01:03 +0000 | [diff] [blame] | 172 | # shellcheck disable=SC2034 |
| 173 | # shellcheck disable=SC2046 |
| 174 | read -r common_repo \ |
liamfallon | 81c2c51 | 2021-12-16 12:56:37 +0000 | [diff] [blame] | 175 | common_latest_released_tag \ |
| 176 | common_latest_snapshot_tag \ |
| 177 | common_changed_files \ |
| 178 | common_docker_images \ |
liamfallon | d7d9a66 | 2022-03-01 21:01:03 +0000 | [diff] [blame] | 179 | <<< $(grep policy/common "$release_data_file" | tr ',' ' ' ) |
liamfallon | 81c2c51 | 2021-12-16 12:56:37 +0000 | [diff] [blame] | 180 | |
liamfallon | d7d9a66 | 2022-03-01 21:01:03 +0000 | [diff] [blame] | 181 | # shellcheck disable=SC2034 |
| 182 | # shellcheck disable=SC2046 |
| 183 | read -r docker_repo \ |
liamfallon | 81c2c51 | 2021-12-16 12:56:37 +0000 | [diff] [blame] | 184 | docker_latest_released_tag \ |
| 185 | docker_latest_snapshot_tag \ |
| 186 | docker_changed_files \ |
| 187 | docker_docker_images \ |
liamfallon | d7d9a66 | 2022-03-01 21:01:03 +0000 | [diff] [blame] | 188 | <<< $(grep policy/docker "$release_data_file" | tr ',' ' ' ) |
liamfallon | 81c2c51 | 2021-12-16 12:56:37 +0000 | [diff] [blame] | 189 | |
liamfallon | d7d9a66 | 2022-03-01 21:01:03 +0000 | [diff] [blame] | 190 | # shellcheck disable=SC2034 |
| 191 | # shellcheck disable=SC2046 |
| 192 | read -r models_repo \ |
liamfallon | 81c2c51 | 2021-12-16 12:56:37 +0000 | [diff] [blame] | 193 | models_latest_released_tag \ |
| 194 | models_latest_snapshot_tag \ |
| 195 | models_changed_files \ |
| 196 | models_docker_images \ |
liamfallon | d7d9a66 | 2022-03-01 21:01:03 +0000 | [diff] [blame] | 197 | <<< $(grep policy/models "$release_data_file" | tr ',' ' ' ) |
liamfallon | 81c2c51 | 2021-12-16 12:56:37 +0000 | [diff] [blame] | 198 | |
liamfallon | d7d9a66 | 2022-03-01 21:01:03 +0000 | [diff] [blame] | 199 | # shellcheck disable=SC2034 |
| 200 | # shellcheck disable=SC2046 |
| 201 | read -r drools_pdp_repo \ |
liamfallon | 81c2c51 | 2021-12-16 12:56:37 +0000 | [diff] [blame] | 202 | drools_pdp_latest_released_tag \ |
| 203 | drools_pdp_latest_snapshot_tag \ |
| 204 | drools_pdp_changed_files \ |
| 205 | drools_pdp_docker_images \ |
liamfallon | d7d9a66 | 2022-03-01 21:01:03 +0000 | [diff] [blame] | 206 | <<< $(grep policy/drools-pdp "$release_data_file" | tr ',' ' ' ) |
liamfallon | 81c2c51 | 2021-12-16 12:56:37 +0000 | [diff] [blame] | 207 | |
liamfallon | d7d9a66 | 2022-03-01 21:01:03 +0000 | [diff] [blame] | 208 | # shellcheck disable=SC2034 |
| 209 | # shellcheck disable=SC2046 |
liamfallon | 4d071bf | 2022-03-16 14:27:21 +0000 | [diff] [blame] | 210 | read -r apex_pdp_repo \ |
| 211 | apex_pdp_latest_released_tag \ |
| 212 | apex_pdp_latest_snapshot_tag \ |
| 213 | apex_pdp_changed_files \ |
| 214 | apex_pdp_docker_images \ |
| 215 | <<< $(grep policy/apex-pdp "$release_data_file" | tr ',' ' ' ) |
| 216 | |
| 217 | # shellcheck disable=SC2034 |
| 218 | # shellcheck disable=SC2046 |
liamfallon | d7d9a66 | 2022-03-01 21:01:03 +0000 | [diff] [blame] | 219 | read -r target_repo \ |
liamfallon | 81c2c51 | 2021-12-16 12:56:37 +0000 | [diff] [blame] | 220 | target_latest_released_tag \ |
| 221 | target_latest_snapshot_tag \ |
| 222 | target_changed_files \ |
| 223 | target_docker_images \ |
liamfallon | d7d9a66 | 2022-03-01 21:01:03 +0000 | [diff] [blame] | 224 | <<< $(grep "$specified_repo" "$release_data_file" | tr ',' ' ' ) |
liamfallon | 81c2c51 | 2021-12-16 12:56:37 +0000 | [diff] [blame] | 225 | |
| 226 | if [ -z "$target_repo" ] |
| 227 | then |
| 228 | echo "specified repo '$specified_repo' not found in policy release data file '$release_data_file'" |
| 229 | exit 1 |
| 230 | fi |
| 231 | |
| 232 | if [ ! "$specified_repo" = "$target_repo" ] |
| 233 | then |
| 234 | echo "specified repo '$specified_repo' does not match target repo '$target_repo'" |
| 235 | exit 1 |
| 236 | fi |
| 237 | |
| 238 | if [ "$update_parent" = true ] |
| 239 | then |
| 240 | if [ "$specified_repo" = "policy/parent" ] |
| 241 | then |
| 242 | if [ "$update_snapshot" = true ] |
| 243 | then |
liamfallon | d7d9a66 | 2022-03-01 21:01:03 +0000 | [diff] [blame] | 244 | major_version=$(echo "$parent_latest_released_tag" | $SED -E 's/^([0-9]*)\.[0-9]*\.[0-9]*$/\1/') |
| 245 | minor_version=$(echo "$parent_latest_released_tag" | $SED -E 's/^[0-9]*\.([0-9]*)\.[0-9]*$/\1/') |
| 246 | patch_version=$(echo "$parent_latest_released_tag" | $SED -E 's/^[0-9]*\.[0-9]*\.([0-9]*)$/\1/') |
liamfallon | d7d9a66 | 2022-03-01 21:01:03 +0000 | [diff] [blame] | 247 | |
liamfallon | 6214bfb | 2022-09-08 16:58:30 +0100 | [diff] [blame^] | 248 | new_patch_version=$((patch_version+1)) |
liamfallon | d7d9a66 | 2022-03-01 21:01:03 +0000 | [diff] [blame] | 249 | new_snapshot_tag="$major_version"."$minor_version"."$new_patch_version"-SNAPSHOT |
| 250 | |
| 251 | echo updating policy parent reference to "$new_snapshot_tag" on "$repo_location/$target_repo" . . . |
liamfallon | b76315a | 2022-01-12 13:24:54 +0000 | [diff] [blame] | 252 | $SED -i \ |
liamfallon | d7d9a66 | 2022-03-01 21:01:03 +0000 | [diff] [blame] | 253 | "s/<version.parent.resources>.*<\/version.parent.resources>/<version.parent.resources>$new_snapshot_tag<\/version.parent.resources>/" \ |
| 254 | "$repo_location/policy/parent/integration/pom.xml" |
liamfallon | 81c2c51 | 2021-12-16 12:56:37 +0000 | [diff] [blame] | 255 | result_code=$? |
| 256 | else |
| 257 | next_release_version=${parent_latest_snapshot_tag%-*} |
| 258 | |
liamfallon | d7d9a66 | 2022-03-01 21:01:03 +0000 | [diff] [blame] | 259 | echo "updating policy parent reference to $next_release_version on $repo_location/$target_repo . . ." |
liamfallon | b76315a | 2022-01-12 13:24:54 +0000 | [diff] [blame] | 260 | $SED -i \ |
liamfallon | 81c2c51 | 2021-12-16 12:56:37 +0000 | [diff] [blame] | 261 | "s/<version.parent.resources>.*<\/version.parent.resources>/<version.parent.resources>$next_release_version<\/version.parent.resources>/" \ |
liamfallon | d7d9a66 | 2022-03-01 21:01:03 +0000 | [diff] [blame] | 262 | "$repo_location/policy/parent/integration/pom.xml" |
liamfallon | 81c2c51 | 2021-12-16 12:56:37 +0000 | [diff] [blame] | 263 | result_code=$? |
| 264 | fi |
| 265 | else |
| 266 | if [ "$update_snapshot" = true ] |
| 267 | then |
liamfallon | d7d9a66 | 2022-03-01 21:01:03 +0000 | [diff] [blame] | 268 | echo "updating policy parent reference to $parent_latest_snapshot_tag on $repo_location/$target_repo . . ." |
liamfallon | 81c2c51 | 2021-12-16 12:56:37 +0000 | [diff] [blame] | 269 | updateParentRef.sh \ |
liamfallon | d7d9a66 | 2022-03-01 21:01:03 +0000 | [diff] [blame] | 270 | -f "$repo_location/$target_repo/pom.xml" \ |
liamfallon | 81c2c51 | 2021-12-16 12:56:37 +0000 | [diff] [blame] | 271 | -g org.onap.policy.parent \ |
| 272 | -a integration \ |
liamfallon | d7d9a66 | 2022-03-01 21:01:03 +0000 | [diff] [blame] | 273 | -v "$parent_latest_snapshot_tag" |
liamfallon | 81c2c51 | 2021-12-16 12:56:37 +0000 | [diff] [blame] | 274 | result_code=$? |
| 275 | else |
liamfallon | d7d9a66 | 2022-03-01 21:01:03 +0000 | [diff] [blame] | 276 | echo "updating policy parent reference to $parent_latest_released_tag on $repo_location/$target_repo . . ." |
liamfallon | 81c2c51 | 2021-12-16 12:56:37 +0000 | [diff] [blame] | 277 | updateParentRef.sh \ |
liamfallon | d7d9a66 | 2022-03-01 21:01:03 +0000 | [diff] [blame] | 278 | -f "$repo_location/$target_repo/pom.xml" \ |
liamfallon | 81c2c51 | 2021-12-16 12:56:37 +0000 | [diff] [blame] | 279 | -g org.onap.policy.parent \ |
| 280 | -a integration \ |
liamfallon | d7d9a66 | 2022-03-01 21:01:03 +0000 | [diff] [blame] | 281 | -v "$parent_latest_released_tag" |
liamfallon | 81c2c51 | 2021-12-16 12:56:37 +0000 | [diff] [blame] | 282 | result_code=$? |
| 283 | fi |
| 284 | fi |
| 285 | if [[ "$result_code" -eq 0 ]] |
| 286 | then |
liamfallon | d7d9a66 | 2022-03-01 21:01:03 +0000 | [diff] [blame] | 287 | echo "policy parent reference updated on $repo_location/$target_repo" |
liamfallon | 81c2c51 | 2021-12-16 12:56:37 +0000 | [diff] [blame] | 288 | else |
liamfallon | d7d9a66 | 2022-03-01 21:01:03 +0000 | [diff] [blame] | 289 | echo "policy parent reference update failed on $repo_location/$target_repo" |
liamfallon | 81c2c51 | 2021-12-16 12:56:37 +0000 | [diff] [blame] | 290 | exit 1 |
| 291 | fi |
| 292 | fi |
| 293 | |
| 294 | if [ "$update_common" = true ] |
| 295 | then |
| 296 | if [ "$update_snapshot" = true ] |
| 297 | then |
liamfallon | d7d9a66 | 2022-03-01 21:01:03 +0000 | [diff] [blame] | 298 | echo "updating policy common reference to $common_latest_snapshot_tag on $repo_location/$target_repo . . ." |
liamfallon | b76315a | 2022-01-12 13:24:54 +0000 | [diff] [blame] | 299 | $SED -i \ |
liamfallon | 81c2c51 | 2021-12-16 12:56:37 +0000 | [diff] [blame] | 300 | -e "s/<policy.common.version>.*<\/policy.common.version>/<policy.common.version>$common_latest_snapshot_tag<\/policy.common.version>/" \ |
| 301 | -e "s/<version.policy.common>.*<\/version.policy.common>/<version.policy.common>$common_latest_snapshot_tag<\/version.policy.common>/" \ |
liamfallon | d7d9a66 | 2022-03-01 21:01:03 +0000 | [diff] [blame] | 302 | "$repo_location/$target_repo/pom.xml" |
liamfallon | 81c2c51 | 2021-12-16 12:56:37 +0000 | [diff] [blame] | 303 | result_code=$? |
| 304 | else |
liamfallon | d7d9a66 | 2022-03-01 21:01:03 +0000 | [diff] [blame] | 305 | echo "updating policy common reference to $common_latest_released_tag on $repo_location/$target_repo . . ." |
liamfallon | b76315a | 2022-01-12 13:24:54 +0000 | [diff] [blame] | 306 | $SED -i \ |
liamfallon | 81c2c51 | 2021-12-16 12:56:37 +0000 | [diff] [blame] | 307 | -e "s/<policy.common.version>.*<\/policy.common.version>/<policy.common.version>$common_latest_released_tag<\/policy.common.version>/" \ |
| 308 | -e "s/<version.policy.common>.*<\/version.policy.common>/<version.policy.common>$common_latest_released_tag<\/version.policy.common>/" \ |
liamfallon | d7d9a66 | 2022-03-01 21:01:03 +0000 | [diff] [blame] | 309 | "$repo_location/$target_repo/pom.xml" |
liamfallon | 81c2c51 | 2021-12-16 12:56:37 +0000 | [diff] [blame] | 310 | result_code=$? |
| 311 | fi |
| 312 | if [[ "$result_code" -eq 0 ]] |
| 313 | then |
liamfallon | d7d9a66 | 2022-03-01 21:01:03 +0000 | [diff] [blame] | 314 | echo "policy common reference updated on $repo_location/$target_repo" |
liamfallon | 81c2c51 | 2021-12-16 12:56:37 +0000 | [diff] [blame] | 315 | else |
liamfallon | d7d9a66 | 2022-03-01 21:01:03 +0000 | [diff] [blame] | 316 | echo "policy common reference update failed on $repo_location/$target_repo" |
liamfallon | 81c2c51 | 2021-12-16 12:56:37 +0000 | [diff] [blame] | 317 | exit 1 |
| 318 | fi |
| 319 | fi |
| 320 | |
| 321 | if [ "$update_models" = true ] |
| 322 | then |
| 323 | if [ "$update_snapshot" = true ] |
| 324 | then |
liamfallon | d7d9a66 | 2022-03-01 21:01:03 +0000 | [diff] [blame] | 325 | echo "updating policy models reference to $models_latest_snapshot_tag on $repo_location/$target_repo . . ." |
liamfallon | b76315a | 2022-01-12 13:24:54 +0000 | [diff] [blame] | 326 | $SED -i \ |
liamfallon | 81c2c51 | 2021-12-16 12:56:37 +0000 | [diff] [blame] | 327 | -e "s/<policy.models.version>.*<\/policy.models.version>/<policy.models.version>$models_latest_snapshot_tag<\/policy.models.version>/" \ |
| 328 | -e "s/<version.policy.models>.*<\/version.policy.models>/<version.policy.models>$models_latest_snapshot_tag<\/version.policy.models>/" \ |
liamfallon | d7d9a66 | 2022-03-01 21:01:03 +0000 | [diff] [blame] | 329 | "$repo_location/$target_repo/pom.xml" |
liamfallon | 81c2c51 | 2021-12-16 12:56:37 +0000 | [diff] [blame] | 330 | result_code=$? |
| 331 | else |
liamfallon | d7d9a66 | 2022-03-01 21:01:03 +0000 | [diff] [blame] | 332 | echo "updating policy models reference to $models_latest_released_tag on $repo_location/$target_repo . . ." |
liamfallon | b76315a | 2022-01-12 13:24:54 +0000 | [diff] [blame] | 333 | $SED -i \ |
liamfallon | 81c2c51 | 2021-12-16 12:56:37 +0000 | [diff] [blame] | 334 | -e "s/<policy.models.version>.*<\/policy.models.version>/<policy.models.version>$models_latest_released_tag<\/policy.models.version>/" \ |
| 335 | -e "s/<version.policy.models>.*<\/version.policy.models>/<version.policy.models>$models_latest_released_tag<\/version.policy.models>/" \ |
liamfallon | d7d9a66 | 2022-03-01 21:01:03 +0000 | [diff] [blame] | 336 | "$repo_location/$target_repo/pom.xml" |
liamfallon | 81c2c51 | 2021-12-16 12:56:37 +0000 | [diff] [blame] | 337 | result_code=$? |
| 338 | fi |
| 339 | if [[ "$result_code" -eq 0 ]] |
| 340 | then |
liamfallon | d7d9a66 | 2022-03-01 21:01:03 +0000 | [diff] [blame] | 341 | echo "policy models reference updated on $repo_location/$target_repo" |
liamfallon | 81c2c51 | 2021-12-16 12:56:37 +0000 | [diff] [blame] | 342 | else |
liamfallon | d7d9a66 | 2022-03-01 21:01:03 +0000 | [diff] [blame] | 343 | echo "policy models reference update failed on $repo_location/$target_repo" |
liamfallon | 81c2c51 | 2021-12-16 12:56:37 +0000 | [diff] [blame] | 344 | exit 1 |
| 345 | fi |
| 346 | fi |
| 347 | |
| 348 | if [ "$update_drools_pdp" = true ] |
| 349 | then |
| 350 | if [ "$update_snapshot" = true ] |
| 351 | then |
liamfallon | d7d9a66 | 2022-03-01 21:01:03 +0000 | [diff] [blame] | 352 | echo "updating policy drools-pdp reference to $drools_pdp_latest_snapshot_tag on $repo_location/$target_repo . . ." |
liamfallon | b76315a | 2022-01-12 13:24:54 +0000 | [diff] [blame] | 353 | $SED -i \ |
liamfallon | 81c2c51 | 2021-12-16 12:56:37 +0000 | [diff] [blame] | 354 | -e "s/<policy.drools-pdp.version>.*<\/policy.drools-pdp.version>/<policy.drools-pdp.version>$drools_pdp_latest_snapshot_tag<\/policy.drools-pdp.version>/" \ |
| 355 | -e "s/<version.policy.drools-pdp>.*<\/version.policy.drools-pdp>/<version.policy.drools-pdp>$drools_pdp_latest_snapshot_tag<\/version.policy.drools-pdp>/" \ |
liamfallon | d7d9a66 | 2022-03-01 21:01:03 +0000 | [diff] [blame] | 356 | "$repo_location/$target_repo/pom.xml" |
liamfallon | 81c2c51 | 2021-12-16 12:56:37 +0000 | [diff] [blame] | 357 | result_code=$? |
| 358 | else |
liamfallon | d7d9a66 | 2022-03-01 21:01:03 +0000 | [diff] [blame] | 359 | echo "updating policy drools-pdp reference to $drools_pdp_latest_released_tag on $repo_location/$target_repo . . ." |
liamfallon | b76315a | 2022-01-12 13:24:54 +0000 | [diff] [blame] | 360 | $SED -i \ |
liamfallon | 81c2c51 | 2021-12-16 12:56:37 +0000 | [diff] [blame] | 361 | -e "s/<policy.drools-pdp.version>.*<\/policy.drools-pdp.version>/<policy.drools-pdp.version>$drools_pdp_latest_released_tag<\/policy.drools-pdp.version>/" \ |
| 362 | -e "s/<version.policy.drools-pdp>.*<\/version.policy.drools-pdp>/<version.policy.drools-pdp>$drools_pdp_latest_released_tag<\/version.policy.drools-pdp>/" \ |
liamfallon | d7d9a66 | 2022-03-01 21:01:03 +0000 | [diff] [blame] | 363 | "$repo_location/$target_repo/pom.xml" |
liamfallon | 81c2c51 | 2021-12-16 12:56:37 +0000 | [diff] [blame] | 364 | result_code=$? |
| 365 | fi |
| 366 | if [[ "$result_code" -eq 0 ]] |
| 367 | then |
liamfallon | d7d9a66 | 2022-03-01 21:01:03 +0000 | [diff] [blame] | 368 | echo "policy drools-pdp reference updated on $repo_location/$target_repo" |
liamfallon | 81c2c51 | 2021-12-16 12:56:37 +0000 | [diff] [blame] | 369 | else |
liamfallon | d7d9a66 | 2022-03-01 21:01:03 +0000 | [diff] [blame] | 370 | echo "policy drools-pdp reference update failed on $repo_location/$target_repo" |
liamfallon | 81c2c51 | 2021-12-16 12:56:37 +0000 | [diff] [blame] | 371 | exit 1 |
| 372 | fi |
| 373 | fi |
| 374 | |
liamfallon | 4d071bf | 2022-03-16 14:27:21 +0000 | [diff] [blame] | 375 | if [ "$update_apex_pdp" = true ] |
| 376 | then |
| 377 | if [ "$update_snapshot" = true ] |
| 378 | then |
| 379 | echo "updating policy apex-pdp reference to $apex_pdp_latest_snapshot_tag on $repo_location/$target_repo . . ." |
| 380 | $SED -i \ |
| 381 | -e "s/<policy.apex-pdp.version>.*<\/policy.apex-pdp.version>/<policy.apex-pdp.version>$apex_pdp_latest_snapshot_tag<\/policy.apex-pdp.version>/" \ |
| 382 | -e "s/<version.policy.apex-pdp>.*<\/version.policy.apex-pdp>/<version.policy.apex-pdp>$apex_pdp_latest_snapshot_tag<\/version.policy.apex-pdp>/" \ |
| 383 | "$repo_location/$target_repo/pom.xml" |
| 384 | result_code=$? |
| 385 | else |
| 386 | echo "updating policy apex-pdp reference to $apex_pdp_latest_released_tag on $repo_location/$target_repo . . ." |
| 387 | $SED -i \ |
| 388 | -e "s/<policy.apex-pdp.version>.*<\/policy.apex-pdp.version>/<policy.apex-pdp.version>$apex_pdp_latest_released_tag<\/policy.apex-pdp.version>/" \ |
| 389 | -e "s/<version.policy.apex-pdp>.*<\/version.policy.apex-pdp>/<version.policy.apex-pdp>$apex_pdp_latest_released_tag<\/version.policy.apex-pdp>/" \ |
| 390 | "$repo_location/$target_repo/pom.xml" |
| 391 | result_code=$? |
| 392 | fi |
| 393 | if [[ "$result_code" -eq 0 ]] |
| 394 | then |
| 395 | echo "policy apex-pdp reference updated on $repo_location/$target_repo" |
| 396 | else |
| 397 | echo "policy apex-pdp reference update failed on $repo_location/$target_repo" |
| 398 | exit 1 |
| 399 | fi |
| 400 | fi |
| 401 | |
liamfallon | 81c2c51 | 2021-12-16 12:56:37 +0000 | [diff] [blame] | 402 | if [ "$update_docker" = true ] && [ "$target_docker_images" != "" ] |
| 403 | then |
liamfallon | 2da18f6 | 2022-07-29 13:35:49 +0100 | [diff] [blame] | 404 | if [ "$update_snapshot" == true ] |
| 405 | then |
liamfallon | 6214bfb | 2022-09-08 16:58:30 +0100 | [diff] [blame^] | 406 | echo "updating docker base images to version $docker_latest_snapshot_tag on repo $repo_location/$target_repo . . ." |
liamfallon | 2da18f6 | 2022-07-29 13:35:49 +0100 | [diff] [blame] | 407 | find "$repo_location/$target_repo" \ |
| 408 | -name '*Docker*' \ |
liamfallon | 6214bfb | 2022-09-08 16:58:30 +0100 | [diff] [blame^] | 409 | -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/" {} \; |
liamfallon | 2da18f6 | 2022-07-29 13:35:49 +0100 | [diff] [blame] | 410 | result_code=$? |
| 411 | else |
liamfallon | 6214bfb | 2022-09-08 16:58:30 +0100 | [diff] [blame^] | 412 | echo "updating docker base images to version $docker_latest_released_tag on repo $repo_location/$target_repo . . ." |
liamfallon | 2da18f6 | 2022-07-29 13:35:49 +0100 | [diff] [blame] | 413 | find "$repo_location/$target_repo" \ |
| 414 | -name '*Docker*' \ |
liamfallon | 6214bfb | 2022-09-08 16:58:30 +0100 | [diff] [blame^] | 415 | -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/" {} \; |
liamfallon | 2da18f6 | 2022-07-29 13:35:49 +0100 | [diff] [blame] | 416 | result_code=$? |
| 417 | fi |
| 418 | |
liamfallon | 81c2c51 | 2021-12-16 12:56:37 +0000 | [diff] [blame] | 419 | if [[ "$result_code" -eq 0 ]] |
| 420 | then |
liamfallon | d7d9a66 | 2022-03-01 21:01:03 +0000 | [diff] [blame] | 421 | echo "docker base images updated on $repo_location/$target_repo" |
liamfallon | 81c2c51 | 2021-12-16 12:56:37 +0000 | [diff] [blame] | 422 | else |
liamfallon | d7d9a66 | 2022-03-01 21:01:03 +0000 | [diff] [blame] | 423 | echo "docker base images update failed on $repo_location/$target_repo" |
liamfallon | 81c2c51 | 2021-12-16 12:56:37 +0000 | [diff] [blame] | 424 | exit 1 |
| 425 | fi |
| 426 | fi |
liamfallon | 5555653 | 2022-07-13 11:40:56 +0100 | [diff] [blame] | 427 | |
| 428 | if [ "$update_file" = true ] |
| 429 | then |
| 430 | if [ ! "$target_repo" = "policy/parent" ] |
| 431 | then |
| 432 | echo "update of data file can only be done on the policy/parent repo" |
| 433 | exit 1 |
| 434 | fi |
| 435 | |
| 436 | echo "updating release data at $repo_location/$target_repo/integration/src/main/resources/release . . ." |
| 437 | cp "$release_data_file" "$repo_location/$target_repo"/integration/src/main/resources/release |
| 438 | echo "updated release data at $repo_location/$target_repo/integration/src/main/resources/release" |
| 439 | fi |