@@ -34,31 +34,39 @@ spec:
34
34
script : |
35
35
#!/usr/bin/env bash
36
36
set -eo pipefail
37
- echo "Released Version : $(params.RELEASED_VERSION)"
38
- get-resource "snapshot" $(params.SNAPSHOT) > /tmp/snapshot.json
39
- cat /tmp/snapshot.json
40
- file="/tmp/snapshot.json"
41
- container_images=($(jq -r '.spec.components[].containerImage' "$file"))
37
+ release=$(params.RELEASED_VERSION)
38
+ snapshot=$(params.SNAPSHOT)
39
+ echo "Released Version : release"
42
40
41
+ file="/tmp/snapshot.json"
43
42
TARGET_REGISTRY="quay.io/openshift-pipeline"
44
43
SOURCE_PATTEN="quay.io/.*/(pipeline-)?(.*@sha256:.+)"
45
44
TARGET_PATTEN="${TARGET_REGISTRY}/pipelines-\2"
46
- BUNDLE_SOURCE_PATTEN="quay.io/.*/(.*)-rhel9 (@sha256:.+)"
45
+ BUNDLE_SOURCE_PATTEN="quay.io/.*/(.*)-rhel[0-9] (@sha256:.+)"
47
46
BUNDLE_TARGET_PATTEN="$TARGET_REGISTRY/pipelines-\1\2"
48
-
49
- for container_image in "${container_images[@]}"; do
47
+
48
+ get-resource "snapshot" $snapshot > $file
49
+
50
+ component_name=$(jq '.metadata.labels."appstudio.openshift.io/component"' $file | tr -d '"')
51
+
52
+ jq -c '.spec.components[]' /tmp/snapshot.json | while read -r component ; do
53
+ name=$(echo $component | jq -r .name)
54
+ if [[ "$name" = "$component_name" ]]; then
55
+ echo "Releasing Component : $component_name"
56
+ container_image=$(echo $component | jq -r .containerImage)
50
57
if [[ $container_image = *'operator-bundle'* ]]; then
51
58
new_image=$(echo "$container_image" | sed -E "s|$BUNDLE_SOURCE_PATTEN|$BUNDLE_TARGET_PATTEN|g")
52
59
else
53
60
new_image=$(echo "$container_image" | sed -E "s|$SOURCE_PATTEN|$TARGET_PATTEN|g")
54
- new_image=$(echo "$new_image" | sed -E "s/operator-operator-rhel9/rhel9-operator/g")
61
+ new_image=$(echo "$new_image" | sed -E "s/operator-operator-rhel9/rhel9-operator/g")
55
62
fi
56
63
echo "Component Image updated for release : $new_image"
57
64
sha=${new_image/*@sha256:/}
58
65
new_image=${new_image/@sha256:*/}
59
- tags=($(params.RELEASED_VERSION) ${ sha} )
66
+ tags=($release $ sha)
60
67
for tag in "${tags[@]}"; do
61
68
echo "copying the image from $container_image to $new_image with tag $tag and preserving digests"
62
69
skopeo copy docker://"$container_image" docker://"$new_image:$tag" --all --preserve-digests
63
70
done
71
+ fi
64
72
done
0 commit comments