3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
18 TARGET
=${3:-candidate}
19 echo "==========================================================="
20 echo Promoting charms and snaps from
$SOURCE to
$TARGET
23 for snap
in osmclient
; do
25 echo "==========================================================="
28 track
="${CHANNEL}/${SOURCE}\\*"
29 SOURCE_REV
=$
(snapcraft revisions
$snap |
grep $track |
tail -1 |
awk '{print $1}')
30 track
="${CHANNEL}/${TARGET}\\*"
31 TARGET_REV
=$
(snapcraft revisions
$snap |
grep $track |
tail -1 |
awk '{print $1}')
33 echo "$SOURCE: $SOURCE_REV, $TARGET: $TARGET_REV"
35 if [ -z $TARGET_REV ] ||
[ $SOURCE_REV -ne $TARGET_REV ]; then
36 echo "Promoting $SOURCE_REV to beta in place of $TARGET_REV"
37 track
="${CHANNEL}/${TARGET}"
38 snapcraft release
$snap $SOURCE_REV $track
47 'mongodb-exporter-k8s' \
48 'mysqld-exporter-k8s' \
56 'osm-vca-integrator' ; do
58 echo "==========================================================="
61 charmcraft status
$charm --format json
> ${charm}.json
62 isCharm
=$
(grep architecture
${charm}.json |
wc -l 2>/dev
/null
)
65 if [ $isCharm -gt 0 ]; then
67 is2204
=$
(cat ${charm}.json | jq
-r ".[] | select(.track==\"$CHANNEL\") | .mappings[] | select(.base.architecture==\"amd64\" and .base.channel==\"22.04\")"|
wc -l)
68 if [ $is2204 -gt 0 ]; then
73 SOURCE_REV
=$
(cat ${charm}.json | jq
-r ".[] | select(.track==\"$CHANNEL\") | .mappings[] | select(.base.architecture==\"amd64\" and .base.channel==\"$base\") | .releases[] | select(.channel==\"$CHANNEL/$SOURCE\")| .version"|
head -1)
74 TARGET_REV
=$
(cat ${charm}.json | jq
-r ".[] | select(.track==\"$CHANNEL\") | .mappings[] | select(.base.architecture==\"amd64\" and .base.channel==\"$base\") | .releases[] | select(.channel==\"$CHANNEL/$TARGET\")| .version"|
head -1)
78 while [ $index -lt 5 ]; do
79 resourceName
=$
(cat ${charm}.json | jq
-r ".[] | select(.track==\"$CHANNEL\") | .mappings[] | select(.base.architecture==\"amd64\" and .base.channel==\"$base\") | .releases[] | select(.channel==\"$CHANNEL/$SOURCE\")| .resources[$index].name"|
head -1)
80 resourceRevs
=$
(cat ${charm}.json | jq
-r ".[] | select(.track==\"$CHANNEL\") | .mappings[] | select(.base.architecture==\"amd64\" and .base.channel==\"$base\") | .releases[] | select(.channel==\"$CHANNEL/$SOURCE\")| .resources[$index].revision"|
head -1)
81 if [ "$resourceName" != "null" ] ; then
82 resourceArgument
=" $resourceArgument --resource ${resourceName}:${resourceRevs}"
89 SOURCE_REV
=$
(cat ${charm}.json | jq
-r ".[] | select(.track==\"$CHANNEL\") | .mappings[].releases[] | select(.channel==\"$CHANNEL/$SOURCE\")| .version"|
head -1)
90 TARGET_REV
=$
(cat ${charm}.json | jq
-r ".[] | select(.track==\"$CHANNEL\") | .mappings[].releases[] | select(.channel==\"$CHANNEL/$TARGET\")| .version"|
head -1)
94 echo "$SOURCE: $SOURCE_REV, $TARGET: $TARGET_REV $resourceArgument"
96 if [ $TARGET_REV == "null" ] ||
[ $SOURCE_REV -gt $TARGET_REV ] ; then
97 echo Promoting
${charm} revision ${SOURCE_REV} to ${TARGET} ${resourceArgument}
98 charmcraft release
${charm} --revision=${SOURCE_REV} ${resourceArgument} --channel=${CHANNEL}/$TARGET