Update release scripts: OOM and tagging
[policy/parent.git] / integration / src / main / scripts / release / releasePhase.sh
1 #!/bin/bash
2
3 #
4 # ============LICENSE_START================================================
5 # ONAP
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
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
25 SCRIPT_NAME=$(basename "$0")
26 repo_location="./"
27 release_data_file="pf_release_data.csv"
28 release_data_file_tag=""
29
30 usage()
31 {
32     echo ""
33     echo "$SCRIPT_NAME - execute a certain policy framework release phase"
34     echo ""
35     echo "       usage:  $SCRIPT_NAME [-options]"
36     echo ""
37     echo "       options"
38     echo "         -h           - this help message"
39     echo "         -d data_file - the policy release data file to use, defaults to '$release_data_file'"
40     echo "         -l location  - the location of the policy framework repos on the file system,"
41     echo "                        defaults to '$repo_location'"
42     echo "         -i issue-id  - issue ID in the format POLICY-nnnn"
43     echo "         -p phase     - the release phase, a positive integer"
44     echo "         -t tag       - tag the release data file with the given tag"
45     echo ""
46     echo " examples:"
47     echo "  $SCRIPT_NAME -l /home/user/onap -d /home/user/data/pf_release_data.csv -i POLICY-1234 -p 3"
48     echo "    perform release phase 3 on the repos at location '/home/user/onap' using the release data"
49     echo "    in the file '/home/user/data/pf_release_data.csv'"
50     exit 255;
51 }
52
53 while getopts "hd:l:i:p:t:" opt
54 do
55     case $opt in
56     h)
57         usage
58         ;;
59     d)
60         release_data_file=$OPTARG
61         ;;
62     l)
63         repo_location=$OPTARG
64         ;;
65     i)
66         issue_id=$OPTARG
67         ;;
68     p)
69         release_phase=$OPTARG
70         ;;
71     t)
72         release_data_file_tag="$OPTARG"
73         ;;
74     \?)
75         usage
76         exit 1
77         ;;
78     esac
79 done
80
81 if [ $OPTIND -eq 1 ]
82 then
83     echo "no arguments were specified"
84     usage
85 fi
86
87 if [[ -z "$repo_location" ]]
88 then
89     echo "policy repo location not specified on -l flag"
90     exit 1
91 fi
92
93 if ! [ -d "$repo_location" ]
94 then
95     echo "policy repo location '$repo_location' not found"
96     exit 1
97 fi
98
99 if [[ -z "$release_data_file" ]]
100 then
101     echo "policy release data file not specified on -d flag"
102     exit 1
103 fi
104
105 if ! [ -f "$release_data_file" ]
106 then
107     echo "policy release data file '$release_data_file' not found"
108     exit 1
109 fi
110
111 if [ -z "$issue_id" ]
112 then
113     echo "issue_id not specified on -i flag"
114     exit 1
115 fi
116
117 if ! echo "$issue_id" | grep -Eq '^POLICY-[0-9]*$'
118 then
119   echo "issue ID is invalid, it should be of form 'POLICY-nnnn'"
120   exit 1
121 fi
122
123 if [ -z "$release_phase" ]
124 then
125     echo "release_phase not specified on -p flag"
126     exit 1
127 fi
128
129 if ! [[ "$release_phase" =~ ^[0-9]+$ ]]
130 then
131   echo "release_phase is invalid, it should be a positive integer"
132   exit 1
133 fi
134
135 release_phase_1() {
136     echo "Updating parent references in the parent pom and generating commit . . ."
137     updateRefs.sh -d "$release_data_file" -l "$repo_location" -r policy/parent -p
138     generateCommit.sh \
139         -l "$repo_location" \
140         -r policy/parent \
141         -i "$issue_id" \
142         -e "update parent references in policy/parent pom" \
143         -m "updated the parent references in the policy/parent pom"
144     echo "Updated parent references in the parent pom and generated commit"
145 }
146
147 release_phase_2() {
148     echo "Generating artifact release yaml file and commit for policy/parent . . ."
149     releaseRepo.sh -d "$release_data_file" -l "$repo_location" -r policy/parent -i "$issue_id"
150     echo "Generated artifact release yaml file and commit for policy/parent"
151 }
152
153 release_phase_3() {
154     echo "Updating snapshots for policy/parent, updating references on policy/docker and policy/common . . ."
155     bumpSnapshots.sh \
156         -d "$release_data_file" \
157         -l "$repo_location" \
158         -i "$issue_id"
159     updateRefs.sh \
160         -pk \
161         -d "$release_data_file" \
162         -l "$repo_location" \
163         -r "policy/docker"
164     updateRefs.sh \
165         -p \
166         -d "$release_data_file" \
167         -l "$repo_location" \
168         -r "policy/common"
169     generateCommit.sh \
170         -l "$repo_location" \
171         -r "policy/docker" \
172         -i "$issue_id" \
173         -e "update parent references in policy/docker pom" \
174         -m "updated the parent references in the policy/docker pom"
175     generateCommit.sh \
176         -l "$repo_location" \
177         -r "policy/common" \
178         -i "$issue_id" \
179         -e "update parent references in policy/common pom" \
180         -m "updated the parent references in the policy/common pom"
181     echo "Updated snapshots for policy/parent, updating references on policy/docker and policy/common"
182 }
183
184 release_phase_4() {
185     echo "Generating artifact release yaml file and commit for policy/common . . ."
186     releaseRepo.sh -d "$release_data_file" -l "$repo_location" -r policy/common -i "$issue_id"
187     echo "Generated artifact release yaml file and commit for policy/common"
188
189     echo "Generating docker release yaml file and commit for policy/docker . . ."
190     releaseRepoImages.sh -d "$release_data_file" -l "$repo_location" -r policy/docker -i "$issue_id"
191     echo "Generated docker release yaml file and commit for policy/docker"
192 }
193
194 release_phase_5() {
195     echo "Updating snapshots for policy/common and policy/docker, updating references on policy/models . . ."
196     bumpSnapshots.sh \
197         -d "$release_data_file" \
198         -l "$repo_location" \
199         -i "$issue_id"
200     updateRefs.sh \
201         -pck \
202         -d "$release_data_file" \
203         -l "$repo_location" \
204         -r "policy/models"
205     generateCommit.sh \
206         -l "$repo_location" \
207         -r "policy/models" \
208         -i "$issue_id" \
209         -e "update parent,common references in policy/models pom" \
210         -m "updated the parent and common references in the policy/models pom"
211     echo "Updated snapshots for policy/common and policy/docker, updated references on policy/models"
212 }
213
214 release_phase_6() {
215     echo "Generating artifact release yaml file and commit for policy/models . . ."
216     releaseRepo.sh -d "$release_data_file" -l "$repo_location" -r policy/models -i "$issue_id"
217     echo "Generated artifact release yaml file and commit for policy/models"
218 }
219
220 release_phase_7() {
221     echo "Generating docker release yaml file and commit for policy/models . . ."
222     releaseRepoImages.sh -d "$release_data_file" -l "$repo_location" -r policy/models -i "$issue_id"
223     echo "Generated docker release yaml file and commit for policy/models"
224 }
225
226 release_phase_8() {
227     echo "Updating snapshots for policy/models, updating references on other repos . . ."
228     bumpSnapshots.sh \
229         -d "$release_data_file" \
230         -l "$repo_location" \
231         -i "$issue_id"
232     updateRefs.sh \
233         -pcmk \
234         -d "$release_data_file" \
235         -l "$repo_location" \
236         -r "policy/apex-pdp"
237     updateRefs.sh \
238         -pcmk \
239         -d "$release_data_file" \
240         -l "$repo_location" \
241         -r "policy/api"
242     updateRefs.sh \
243         -pcmk \
244         -d "$release_data_file" \
245         -l "$repo_location" \
246         -r "policy/clamp"
247     updateRefs.sh \
248         -pcmk \
249         -d "$release_data_file" \
250         -l "$repo_location" \
251         -r "policy/distribution"
252     updateRefs.sh \
253         -pcmk \
254         -d "$release_data_file" \
255         -l "$repo_location" \
256         -r "policy/drools-pdp"
257     updateRefs.sh \
258         -pcmk \
259         -d "$release_data_file" \
260         -l "$repo_location" \
261         -r "policy/pap"
262     updateRefs.sh \
263         -pcmk \
264         -d "$release_data_file" \
265         -l "$repo_location" \
266         -r "policy/xacml-pdp"
267     generateCommit.sh \
268         -l "$repo_location" \
269         -r "policy/apex-pdp" \
270         -i "$issue_id" \
271         -e "update references in policy/apex-pdp pom" \
272         -m "updated references in the policy/apex-pdp pom"
273     generateCommit.sh \
274         -l "$repo_location" \
275         -r "policy/api" \
276         -i "$issue_id" \
277         -e "update references in policy/api pom" \
278         -m "updated references in the policy/api pom"
279     generateCommit.sh \
280         -l "$repo_location" \
281         -r "policy/clamp" \
282         -i "$issue_id" \
283         -e "update references in policy/clamp pom" \
284         -m "updated references in the policy/clamp pom"
285     generateCommit.sh \
286         -l "$repo_location" \
287         -r "policy/distribution" \
288         -i "$issue_id" \
289         -e "update references in policy/distribution pom" \
290         -m "updated references in the policy/distribution pom"
291     generateCommit.sh \
292         -l "$repo_location" \
293         -r "policy/drools-pdp" \
294         -i "$issue_id" \
295         -e "update references in policy/drools-pdp pom" \
296         -m "updated references in the policy/drools-pdp pom"
297     generateCommit.sh \
298         -l "$repo_location" \
299         -r "policy/pap" \
300         -i "$issue_id" \
301         -e "update references in policy/pap pom" \
302         -m "updated references in the policy/pap pom"
303     generateCommit.sh \
304         -l "$repo_location" \
305         -r "policy/xacml-pdp" \
306         -i "$issue_id" \
307         -e "update references in policy/xacml-pdp pom" \
308         -m "updated references in the policy/xacml-pdp pom"
309     echo "Updated snapshots for policy/models, updated references on other repos"
310 }
311
312 release_phase_9() {
313     echo "Generating artifact release yaml file and commit for repos . . ."
314     releaseRepo.sh -d "$release_data_file" -l "$repo_location" -r policy/apex-pdp -i "$issue_id"
315     releaseRepo.sh -d "$release_data_file" -l "$repo_location" -r policy/api -i "$issue_id"
316     releaseRepo.sh -d "$release_data_file" -l "$repo_location" -r policy/clamp -i "$issue_id"
317     releaseRepo.sh -d "$release_data_file" -l "$repo_location" -r policy/distribution -i "$issue_id"
318     releaseRepo.sh -d "$release_data_file" -l "$repo_location" -r policy/drools-pdp -i "$issue_id"
319     releaseRepo.sh -d "$release_data_file" -l "$repo_location" -r policy/pap -i "$issue_id"
320     releaseRepo.sh -d "$release_data_file" -l "$repo_location" -r policy/xacml-pdp -i "$issue_id"
321     echo "Generated artifact release yaml file and commit for repos"
322 }
323
324 release_phase_10() {
325     echo "Generating docker release yaml file and commit for repos . . ."
326     releaseRepoImages.sh -d "$release_data_file" -l "$repo_location" -r policy/apex-pdp -i "$issue_id"
327     releaseRepoImages.sh -d "$release_data_file" -l "$repo_location" -r policy/api -i "$issue_id"
328     releaseRepoImages.sh -d "$release_data_file" -l "$repo_location" -r policy/clamp -i "$issue_id"
329     releaseRepoImages.sh -d "$release_data_file" -l "$repo_location" -r policy/distribution -i "$issue_id"
330     releaseRepoImages.sh -d "$release_data_file" -l "$repo_location" -r policy/drools-pdp -i "$issue_id"
331     releaseRepoImages.sh -d "$release_data_file" -l "$repo_location" -r policy/pap -i "$issue_id"
332     releaseRepoImages.sh -d "$release_data_file" -l "$repo_location" -r policy/xacml-pdp -i "$issue_id"
333     echo "Generated docker release yaml file and commit for repos"
334 }
335
336 release_phase_11() {
337     echo "Updating snapshots for repos, updating references on policy/drools-applications, policy/gui . . ."
338     bumpSnapshots.sh \
339         -d "$release_data_file" \
340         -l "$repo_location" \
341         -i "$issue_id"
342     updateRefs.sh \
343         -pcmok \
344         -d "$release_data_file" \
345         -l "$repo_location" \
346         -r "policy/drools-applications"
347     updateRefs.sh \
348         -pcmxk \
349         -d "$release_data_file" \
350         -l "$repo_location" \
351         -r "policy/gui"
352     generateCommit.sh \
353         -l "$repo_location" \
354         -r "policy/drools-applications" \
355         -i "$issue_id" \
356         -e "update references in policy/drools-applications pom" \
357         -m "updated references in the policy/drools-applications pom"
358     generateCommit.sh \
359         -l "$repo_location" \
360         -r "policy/gui" \
361         -i "$issue_id" \
362         -e "update references in policy/gui pom" \
363         -m "updated references in the policy/gui pom"
364     echo "Updated snapshots for repos, updated references on policy/drools-applications, policy/gui"
365 }
366
367 release_phase_12() {
368     echo "Generating artifact release yaml file and commit for policy/drools-applications . . ."
369     releaseRepo.sh -d "$release_data_file" -l "$repo_location" -r policy/drools-applications -i "$issue_id"
370     releaseRepo.sh -d "$release_data_file" -l "$repo_location" -r policy/gui -i "$issue_id"
371     echo "Generated artifact release yaml file and commit for policy/drools-applications"
372 }
373
374 release_phase_13() {
375     echo "Generating docker release yaml file and commit for policy/drools-applications . . ."
376     releaseRepoImages.sh -d "$release_data_file" -l "$repo_location" -r policy/drools-applications -i "$issue_id"
377     releaseRepoImages.sh -d "$release_data_file" -l "$repo_location" -r policy/gui -i "$issue_id"
378     echo "Generated docker release yaml file and commit for policy/drools-applications"
379 }
380
381 release_phase_14() {
382     echo "Updating snapshots on policy/drools-applications and policy/gui . . ."
383     bumpSnapshots.sh \
384         -d "$release_data_file" \
385         -l "$repo_location" \
386         -i "$issue_id"
387     echo "Updated snapshots on policy/drools-applications and policy/gui"
388 }
389
390
391 release_phase_15() {
392     echo "Updating release data file . . ."
393     updateRefs.sh \
394         -f \
395         -d "$release_data_file" \
396         -l "$repo_location" \
397         -r "policy/parent" \
398         -t "$release_data_file_tag"
399     generateCommit.sh \
400         -l "$repo_location" \
401         -r "policy/parent" \
402         -i "$issue_id" \
403         -e "update release data in policy/parent" \
404         -m "updated release data in policy/parent"
405     echo "Updated release data file"
406 }
407
408 case "$release_phase" in
409
410 1)  release_phase_1
411     ;;
412
413 2)  release_phase_2
414     ;;
415
416 3)  release_phase_3
417     ;;
418
419 4)  release_phase_4
420     ;;
421
422 5)  release_phase_5
423     ;;
424
425 6)  release_phase_6
426     ;;
427
428 7)  release_phase_7
429     ;;
430
431 8)  release_phase_8
432     ;;
433
434 9)  release_phase_9
435     ;;
436
437 10)  release_phase_10
438     ;;
439
440 11)  release_phase_11
441     ;;
442
443 12)  release_phase_12
444     ;;
445
446 13)  release_phase_13
447     ;;
448
449 14)  release_phase_14
450     ;;
451
452 15)  release_phase_15
453     ;;
454
455 *) echo "specified release phase '$release_phase' is invalid"
456    ;;
457 esac