4 # ============LICENSE_START================================================
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
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==================================================
23 SCRIPT_NAME=$(basename "$0")
25 release_data_file="./pf_release_data.csv"
30 echo "$SCRIPT_NAME - release the specified repository by generating the release yaml file and the release commit"
32 echo " usage: $SCRIPT_NAME [-options]"
35 echo " -h - this help message"
36 echo " -d data_file - the policy release data file to use, defaults to '$release_data_file'"
37 echo " -l location - the location of the policy framework repos on the file system,"
38 echo " defaults to '$repo_location'"
39 echo " -r repo - the policy repo to release"
40 echo " -i issue-id - issue ID in the format POLICY-nnnn"
43 echo " $SCRIPT_NAME -l /home/user/onap -d /home/user/data/pf_release_data.csv -r policy/common -i POLICY-1234"
44 echo " release the 'policy/common' repo at location '/home/user/onap' using the release data"
45 echo " in the file '/home/user/data/pf_release_data.csv'"
49 while getopts "hd:l:r:i:" opt
56 release_data_file=$OPTARG
62 specified_repo=$OPTARG
76 echo "no arguments were specified"
80 if [[ -z "$repo_location" ]]
82 echo "policy repo location not specified on -l flag"
86 if ! [ -d "$repo_location" ]
88 echo "policy repo location '$repo_location' not found"
92 if [[ -z "$release_data_file" ]]
94 echo "policy release data file not specified on -d flag"
98 if ! [ -f "$release_data_file" ]
100 echo "policy release data file '$release_data_file' not found"
104 if [ -z "$specified_repo" ]
106 echo "repo not specified on -r flag"
110 if [ -z "$issue_id" ]
112 echo "issue_id not specified on -i flag"
116 if ! echo "$issue_id" | grep -Eq '^POLICY-[0-9]*$'
118 echo "issue ID is invalid, it should be of form 'POLICY-nnnn'"
122 # shellcheck disable=SC2034
123 # shellcheck disable=SC2046
125 latest_released_tag \
126 latest_snapshot_tag \
129 <<< $(grep "$specified_repo" "$release_data_file" | tr ',' ' ' )
131 if [ ! "$repo" = "$specified_repo" ]
133 echo "repo '$specified_repo' not found in file 'pf_release_data.csv'"
137 next_release_version=${latest_snapshot_tag%-*}
141 read -r -p "have you run 'stage-release' on the '$repo' repo? " yes_no
149 * ) echo "Please answer 'yes' or 'no'"
154 saved_current_dir=$(pwd)
155 cd "$repo_location/$repo" || exit 1
156 if [ "$docker_images" != "" ]
163 if ! mkart.sh "$mkart_flag"
165 echo "generation of artifact release yaml file failed"
166 cd "$saved_current_dir" || exit 1
170 cd "$saved_current_dir" || exit 1
172 echo "generating commit for $repo release: $latest_released_tag-->$next_release_version . . ."
175 -l "$repo_location" \
178 -e "Release $repo: $next_release_version" \
179 -m "This commit releases repo $repo."
181 echo "commit for $repo release: $latest_released_tag-->$next_release_version generated"