4 # ============LICENSE_START================================================
6 # =========================================================================
7 # Copyright (C) 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
13 # http://www.apache.org/licenses/LICENSE-2.0
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==================================================
25 SCRIPT_NAME=$(basename "$0")
27 release_data_file="./pf_release_data.csv"
29 # Use the bash internal OSTYPE variable to check for MacOS
30 if [[ "$OSTYPE" == "darwin"* ]]
50 "policy/drools-applications"
56 echo "$SCRIPT_NAME - on release changes, generate commits to set the snapshot version and update"
57 echo " references on any repos that reference other repos"
59 echo " usage: $SCRIPT_NAME [-options]"
62 echo " -h - this help message"
63 echo " -d data_file - the policy release data file to use, defaults to '$release_data_file'"
64 echo " -l location - the location of the policy framework repos on the file system,"
65 echo " defaults to '$repo_location'"
66 echo " -i issue-id - issue ID in the format POLICY-nnnn"
69 echo " $SCRIPT_NAME -l /home/user/onap -d /home/user/data/pf_release_data.csv -i POLICY-1234"
70 echo " set snapshots on the repos at location '/home/user/onap' using the release data"
71 echo " in the file '/home/user/data/pf_release_data.csv'"
75 while getopts "hd:l:i:" opt
82 release_data_file=$OPTARG
99 echo "no arguments were specified"
103 if [[ -z "$repo_location" ]]
105 echo "policy repo location not specified on -l flag"
109 if ! [ -d "$repo_location" ]
111 echo "policy repo location '$repo_location' not found"
115 if [[ -z "$release_data_file" ]]
117 echo "policy release data file not specified on -d flag"
121 if ! [ -f "$release_data_file" ]
123 echo "policy release data file '$release_data_file' not found"
127 if [ -z "$issue_id" ]
129 echo "issue_id not specified on -i flag"
133 if ! echo "$issue_id" | grep -Eq '^POLICY-[0-9]*$'
135 echo "issue ID is invalid, it should be of form 'POLICY-nnnn'"
139 for specified_repo in "${pf_repos[@]}"
141 # shellcheck disable=SC2034
142 # shellcheck disable=SC2046
144 latest_released_tag \
145 latest_snapshot_tag \
148 <<< $(grep "$specified_repo" "$release_data_file" | tr ',' ' ' )
150 if [ ! "$repo" = "$specified_repo" ]
152 echo "repo '$specified_repo' not found in file 'pf_release_data.csv'"
156 next_release_version=${latest_snapshot_tag%-*}
158 major_version=$(echo "$latest_released_tag" | $SED -E 's/^([0-9]*)\.[0-9]*\.[0-9]*$/\1/')
159 minor_version=$(echo "$latest_released_tag" | $SED -E 's/^[0-9]*\.([0-9]*)\.[0-9]*$/\1/')
160 patch_version=$(echo "$next_release_version" | $SED -E 's/^[0-9]*\.[0-9]*\.([0-9]*)$/\1/')
161 # shellcheck disable=SC2004
162 new_minor_version=$(($minor_version+1))
164 new_snapshot_tag="$major_version"."$new_minor_version".0-SNAPSHOT
166 echo "updating snapshot version and references of repo $repo to $new_snapshot_tag . . ."
167 mvn -f "$repo_location/$repo" \
168 "-DnewVersion=$new_snapshot_tag" versions:set \
169 versions:update-child-modules versions:commit
173 echo "set snapshot version of repo $repo in $repo_location/$repo/version.properties"
175 -e "s/minor=$minor_version/minor=$new_minor_version/" \
176 -e "s/patch=$patch_version/patch=0/" \
177 "$repo_location/$repo/version.properties" \
179 mv "$temp_file" "$repo_location/$repo/version.properties"
181 updateRefs.sh -pcmoxs -d "$release_data_file" -l "$repo_location" -r "$repo"
184 -l "$repo_location" \
187 -e "Set snapshot and/or references of $repo for new release" \
188 -m "$repo updated to its latest own and reference snapshots"
190 echo "commit to set snapshot version and/or references of repo $repo generated"