summaryrefslogtreecommitdiffstats
path: root/integration/src/main/scripts/release/releasePhase.sh
blob: 789e7f18c99de4fa1aabcc516c579dd363b26eeb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
#!/bin/bash

#
# ============LICENSE_START================================================
# ONAP
# =========================================================================
# Copyright (C) 2022 Nordix Foundation.
# =========================================================================
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ============LICENSE_END==================================================
#

set -e

SCRIPT_NAME=$(basename "$0")
repo_location="./"
release_data_file="pf_release_data.csv"
release_data_file_tag=""

usage()
{
    echo ""
    echo "$SCRIPT_NAME - execute a certain policy framework release phase"
    echo ""
    echo "       usage:  $SCRIPT_NAME [-options]"
    echo ""
    echo "       options"
    echo "         -h           - this help message"
    echo "         -d data_file - the policy release data file to use, defaults to '$release_data_file'"
    echo "         -l location  - the location of the policy framework repos on the file system,"
    echo "                        defaults to '$repo_location'"
    echo "         -i issue-id  - issue ID in the format POLICY-nnnn"
    echo "         -p phase     - the release phase, a positive integer"
    echo "         -t tag       - tag the release data file with the given tag"
    echo ""
    echo " examples:"
    echo "  $SCRIPT_NAME -l /home/user/onap -d /home/user/data/pf_release_data.csv -i POLICY-1234 -p 3"
    echo "    perform release phase 3 on the repos at location '/home/user/onap' using the release data"
    echo "    in the file '/home/user/data/pf_release_data.csv'"
    exit 255;
}

while getopts "hd:l:i:p:t:" opt
do
    case $opt in
    h)
        usage
        ;;
    d)
        release_data_file=$OPTARG
        ;;
    l)
        repo_location=$OPTARG
        ;;
    i)
        issue_id=$OPTARG
        ;;
    p)
        release_phase=$OPTARG
        ;;
    t)
        release_data_file_tag="$OPTARG"
        ;;
    \?)
        usage
        exit 1
        ;;
    esac
done

if [ $OPTIND -eq 1 ]
then
    echo "no arguments were specified"
    usage
fi

if [[ -z "$repo_location" ]]
then
    echo "policy repo location not specified on -l flag"
    exit 1
fi

if ! [ -d "$repo_location" ]
then
    echo "policy repo location '$repo_location' not found"
    exit 1
fi

if [[ -z "$release_data_file" ]]
then
    echo "policy release data file not specified on -d flag"
    exit 1
fi

if ! [ -f "$release_data_file" ]
then
    echo "policy release data file '$release_data_file' not found"
    exit 1
fi

if [ -z "$issue_id" ]
then
    echo "issue_id not specified on -i flag"
    exit 1
fi

if ! echo "$issue_id" | grep -Eq '^POLICY-[0-9]*$'
then
  echo "issue ID is invalid, it should be of form 'POLICY-nnnn'"
  exit 1
fi

if [ -z "$release_phase" ]
then
    echo "release_phase not specified on -p flag"
    exit 1
fi

if ! [[ "$release_phase" =~ ^[0-9]+$ ]]
then
  echo "release_phase is invalid, it should be a positive integer"
  exit 1
fi

release_phase_1() {
    echo "Updating parent references in the parent pom and generating commit . . ."
    updateRefs.sh -d "$release_data_file" -l "$repo_location" -r policy/parent -p
    generateCommit.sh \
        -l "$repo_location" \
        -r policy/parent \
        -i "$issue_id" \
        -e "update parent references in policy/parent pom" \
        -m "updated the parent references in the policy/parent pom"
    echo "Updated parent references in the parent pom and generated commit"
}

release_phase_2() {
    echo "Generating artifact release yaml file and commit for policy/parent . . ."
    releaseRepo.sh -d "$release_data_file" -l "$repo_location" -r policy/parent -i "$issue_id"
    echo "Generated artifact release yaml file and commit for policy/parent"
}

release_phase_3() {
    echo "Updating snapshots for policy/parent, updating references on policy/docker and policy/common . . ."
    bumpSnapshots.sh \
        -d "$release_data_file" \
        -l "$repo_location" \
        -i "$issue_id"
    updateRefs.sh \
        -pk \
        -d "$release_data_file" \
        -l "$repo_location" \
        -r "policy/docker"
    updateRefs.sh \
        -p \
        -d "$release_data_file" \
        -l "$repo_location" \
        -r "policy/common"
    generateCommit.sh \
        -l "$repo_location" \
        -r "policy/docker" \
        -i "$issue_id" \
        -e "update parent references in policy/docker pom" \
        -m "updated the parent references in the policy/docker pom"
    generateCommit.sh \
        -l "$repo_location" \
        -r "policy/common" \
        -i "$issue_id" \
        -e "update parent references in policy/common pom" \
        -m "updated the parent references in the policy/common pom"
    echo "Updated snapshots for policy/parent, updating references on policy/docker and policy/common"
}

release_phase_4() {
    echo "Generating artifact release yaml file and commit for policy/common . . ."
    releaseRepo.sh -d "$release_data_file" -l "$repo_location" -r policy/common -i "$issue_id"
    echo "Generated artifact release yaml file and commit for policy/common"

    echo "Generating docker release yaml file and commit for policy/docker . . ."
    releaseRepoImages.sh -d "$release_data_file" -l "$repo_location" -r policy/docker -i "$issue_id"
    echo "Generated docker release yaml file and commit for policy/docker"
}

release_phase_5() {
    echo "Updating snapshots for policy/common and policy/docker, updating references on policy/models . . ."
    bumpSnapshots.sh \
        -d "$release_data_file" \
        -l "$repo_location" \
        -i "$issue_id"
    updateRefs.sh \
        -pck \
        -d "$release_data_file" \
        -l "$repo_location" \
        -r "policy/models"
    generateCommit.sh \
        -l "$repo_location" \
        -r "policy/models" \
        -i "$issue_id" \
        -e "update parent,common references in policy/models pom" \
        -m "updated the parent and common references in the policy/models pom"
    echo "Updated snapshots for policy/common and policy/docker, updated references on policy/models"
}

release_phase_6() {
    echo "Generating artifact release yaml file and commit for policy/models . . ."
    releaseRepo.sh -d "$release_data_file" -l "$repo_location" -r policy/models -i "$issue_id"
    echo "Generated artifact release yaml file and commit for policy/models"
}

release_phase_7() {
    echo "Generating docker release yaml file and commit for policy/models . . ."
    releaseRepoImages.sh -d "$release_data_file" -l "$repo_location" -r policy/models -i "$issue_id"
    echo "Generated docker release yaml file and commit for policy/models"
}

release_phase_8() {
    echo "Updating snapshots for policy/models, updating references on other repos . . ."
    bumpSnapshots.sh \
        -d "$release_data_file" \
        -l "$repo_location" \
        -i "$issue_id"
    updateRefs.sh \
        -pcmk \
        -d "$release_data_file" \
        -l "$repo_location" \
        -r "policy/apex-pdp"
    updateRefs.sh \
        -pcmk \
        -d "$release_data_file" \
        -l "$repo_location" \
        -r "policy/api"
    updateRefs.sh \
        -pcmk \
        -d "$release_data_file" \
        -l "$repo_location" \
        -r "policy/clamp"
    updateRefs.sh \
        -pcmk \
        -d "$release_data_file" \
        -l "$repo_location" \
        -r "policy/distribution"
    updateRefs.sh \
        -pcmk \
        -d "$release_data_file" \
        -l "$repo_location" \
        -r "policy/drools-pdp"
    updateRefs.sh \
        -pcmk \
        -d "$release_data_file" \
        -l "$repo_location" \
        -r "policy/pap"
    updateRefs.sh \
        -pcmk \
        -d "$release_data_file" \
        -l "$repo_location" \
        -r "policy/xacml-pdp"
    generateCommit.sh \
        -l "$repo_location" \
        -r "policy/apex-pdp" \
        -i "$issue_id" \
        -e "update references in policy/apex-pdp pom" \
        -m "updated references in the policy/apex-pdp pom"
    generateCommit.sh \
        -l "$repo_location" \
        -r "policy/api" \
        -i "$issue_id" \
        -e "update references in policy/api pom" \
        -m "updated references in the policy/api pom"
    generateCommit.sh \
        -l "$repo_location" \
        -r "policy/clamp" \
        -i "$issue_id" \
        -e "update references in policy/clamp pom" \
        -m "updated references in the policy/clamp pom"
    generateCommit.sh \
        -l "$repo_location" \
        -r "policy/distribution" \
        -i "$issue_id" \
        -e "update references in policy/distribution pom" \
        -m "updated references in the policy/distribution pom"
    generateCommit.sh \
        -l "$repo_location" \
        -r "policy/drools-pdp" \
        -i "$issue_id" \
        -e "update references in policy/drools-pdp pom" \
        -m "updated references in the policy/drools-pdp pom"
    generateCommit.sh \
        -l "$repo_location" \
        -r "policy/pap" \
        -i "$issue_id" \
        -e "update references in policy/pap pom" \
        -m "updated references in the policy/pap pom"
    generateCommit.sh \
        -l "$repo_location" \
        -r "policy/xacml-pdp" \
        -i "$issue_id" \
        -e "update references in policy/xacml-pdp pom" \
        -m "updated references in the policy/xacml-pdp pom"
    echo "Updated snapshots for policy/models, updated references on other repos"
}

release_phase_9() {
    echo "Generating artifact release yaml file and commit for repos . . ."
    releaseRepo.sh -d "$release_data_file" -l "$repo_location" -r policy/apex-pdp -i "$issue_id"
    releaseRepo.sh -d "$release_data_file" -l "$repo_location" -r policy/api -i "$issue_id"
    releaseRepo.sh -d "$release_data_file" -l "$repo_location" -r policy/clamp -i "$issue_id"
    releaseRepo.sh -d "$release_data_file" -l "$repo_location" -r policy/distribution -i "$issue_id"
    releaseRepo.sh -d "$release_data_file" -l "$repo_location" -r policy/drools-pdp -i "$issue_id"
    releaseRepo.sh -d "$release_data_file" -l "$repo_location" -r policy/pap -i "$issue_id"
    releaseRepo.sh -d "$release_data_file" -l "$repo_location" -r policy/xacml-pdp -i "$issue_id"
    echo "Generated artifact release yaml file and commit for repos"
}

release_phase_10() {
    echo "Generating docker release yaml file and commit for repos . . ."
    releaseRepoImages.sh -d "$release_data_file" -l "$repo_location" -r policy/apex-pdp -i "$issue_id"
    releaseRepoImages.sh -d "$release_data_file" -l "$repo_location" -r policy/api -i "$issue_id"
    releaseRepoImages.sh -d "$release_data_file" -l "$repo_location" -r policy/clamp -i "$issue_id"
    releaseRepoImages.sh -d "$release_data_file" -l "$repo_location" -r policy/distribution -i "$issue_id"
    releaseRepoImages.sh -d "$release_data_file" -l "$repo_location" -r policy/drools-pdp -i "$issue_id"
    releaseRepoImages.sh -d "$release_data_file" -l "$repo_location" -r policy/pap -i "$issue_id"
    releaseRepoImages.sh -d "$release_data_file" -l "$repo_location" -r policy/xacml-pdp -i "$issue_id"
    echo "Generated docker release yaml file and commit for repos"
}

release_phase_11() {
    echo "Updating snapshots for repos, updating references on policy/drools-applications, policy/gui . . ."
    bumpSnapshots.sh \
        -d "$release_data_file" \
        -l "$repo_location" \
        -i "$issue_id"
    updateRefs.sh \
        -pcmok \
        -d "$release_data_file" \
        -l "$repo_location" \
        -r "policy/drools-applications"
    updateRefs.sh \
        -pcmxk \
        -d "$release_data_file" \
        -l "$repo_location" \
        -r "policy/gui"
    generateCommit.sh \
        -l "$repo_location" \
        -r "policy/drools-applications" \
        -i "$issue_id" \
        -e "update references in policy/drools-applications pom" \
        -m "updated references in the policy/drools-applications pom"
    generateCommit.sh \
        -l "$repo_location" \
        -r "policy/gui" \
        -i "$issue_id" \
        -e "update references in policy/gui pom" \
        -m "updated references in the policy/gui pom"
    echo "Updated snapshots for repos, updated references on policy/drools-applications, policy/gui"
}

release_phase_12() {
    echo "Generating artifact release yaml file and commit for policy/drools-applications . . ."
    releaseRepo.sh -d "$release_data_file" -l "$repo_location" -r policy/drools-applications -i "$issue_id"
    releaseRepo.sh -d "$release_data_file" -l "$repo_location" -r policy/gui -i "$issue_id"
    echo "Generated artifact release yaml file and commit for policy/drools-applications"
}

release_phase_13() {
    echo "Generating docker release yaml file and commit for policy/drools-applications . . ."
    releaseRepoImages.sh -d "$release_data_file" -l "$repo_location" -r policy/drools-applications -i "$issue_id"
    releaseRepoImages.sh -d "$release_data_file" -l "$repo_location" -r policy/gui -i "$issue_id"
    echo "Generated docker release yaml file and commit for policy/drools-applications"
}

release_phase_14() {
    echo "Updating snapshots on policy/drools-applications and policy/gui . . ."
    bumpSnapshots.sh \
        -d "$release_data_file" \
        -l "$repo_location" \
        -i "$issue_id"
    echo "Updated snapshots on policy/drools-applications and policy/gui"
}


release_phase_15() {
    echo "Updating release data file . . ."
    updateRefs.sh \
        -f \
        -d "$release_data_file" \
        -l "$repo_location" \
        -r "policy/parent" \
        -t "$release_data_file_tag"
    generateCommit.sh \
        -l "$repo_location" \
        -r "policy/parent" \
        -i "$issue_id" \
        -e "update release data in policy/parent" \
        -m "updated release data in policy/parent"
    echo "Updated release data file"
}

case "$release_phase" in

1)  release_phase_1
    ;;

2)  release_phase_2
    ;;

3)  release_phase_3
    ;;

4)  release_phase_4
    ;;

5)  release_phase_5
    ;;

6)  release_phase_6
    ;;

7)  release_phase_7
    ;;

8)  release_phase_8
    ;;

9)  release_phase_9
    ;;

10)  release_phase_10
    ;;

11)  release_phase_11
    ;;

12)  release_phase_12
    ;;

13)  release_phase_13
    ;;

14)  release_phase_14
    ;;

15)  release_phase_15
    ;;

*) echo "specified release phase '$release_phase' is invalid"
   ;;
esac