Skip to content

Commit

Permalink
Add release-specific OLM channels (#1403)
Browse files Browse the repository at this point in the history
* Add release-specific OLM channels

Signed-off-by: Michael Edgar <[email protected]>

* fix: use post-release channel when generating new channel file

Signed-off-by: Michael Edgar <[email protected]>

* fix: add release channel to git index during preparation

Signed-off-by: Michael Edgar <[email protected]>

* fix: handle case where the release version differs from last snapshot

Signed-off-by: Michael Edgar <[email protected]>

---------

Signed-off-by: Michael Edgar <[email protected]>
  • Loading branch information
MikeEdgar authored Jan 24, 2025
1 parent 74dd153 commit 01292a8
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 1 deletion.
51 changes: 50 additions & 1 deletion operator/bin/release-prepare.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,26 @@ if [ "${VERSION}" == "${POSTRELEASE_VERSION}" ] ; then
"replaces": "'${RELEASE_CSV_NAME}'"
}' ${OPERATOR_PATH}/src/main/olm/channel.alpha.yaml

POSTRELEASE_CHANNEL=$(echo "${POSTRELEASE_VERSION}" | sed -E 's/([0-9]+)\.([0-9]+)\.[0-9]+(-snapshot)?/\1.\2.x/g')

if [ ! -f ${OPERATOR_PATH}/src/main/olm/channel.${POSTRELEASE_CHANNEL}.yaml ] ; then
echo '---
schema: olm.channel
name: '${POSTRELEASE_CHANNEL}'
package: streamshub-console-operator
properties: []
entries: []' > ${OPERATOR_PATH}/src/main/olm/channel.${POSTRELEASE_CHANNEL}.yaml
fi

# Create new entry for the next development cycle, "replaces" the version just released
${YQ} -i '.entries += {
"name": "'${POSTRELEASE_CSV_NAME}'",
"replaces": "'${RELEASE_CSV_NAME}'"
}' ${OPERATOR_PATH}/src/main/olm/channel.${POSTRELEASE_CHANNEL}.yaml

if [ "${GIT_STAGE}" == "true" ] ; then
git add ${OPERATOR_PATH}/src/main/olm/channel.alpha.yaml
git add ${OPERATOR_PATH}/src/main/olm/channel.${POSTRELEASE_CHANNEL}.yaml
fi
else
# Running via the `preparationGoals` of the maven-release-plugin
Expand All @@ -39,10 +57,41 @@ else
${YQ} -i '(.entries[].name | select(. == "'${PRERELEASE_CSV_NAME}'")) = "'${RELEASE_CSV_NAME}'"' \
${OPERATOR_PATH}/src/main/olm/channel.alpha.yaml

RELEASE_CHANNEL=$(echo "${RELEASE_VERSION}" | sed -E 's/([0-9]+)\.([0-9]+)\.[0-9]+/\1.\2.x/g')

if [ ! -f ${OPERATOR_PATH}/src/main/olm/channel.${RELEASE_CHANNEL}.yaml ] ; then
REPLACES="$(${YQ} '.entries[] | select( .name == "'${RELEASE_CSV_NAME}'") | .replaces' \
${OPERATOR_PATH}/src/main/olm/channel.alpha.yaml)"

echo '---
schema: olm.channel
name: '${RELEASE_CHANNEL}'
package: streamshub-console-operator
properties: []
entries:
- name: '${RELEASE_CSV_NAME}'' > ${OPERATOR_PATH}/src/main/olm/channel.${RELEASE_CHANNEL}.yaml

if [ -n "${REPLACES}" ] ; then
${YQ} -i '(.entries[] | select(.name == "'${RELEASE_CSV_NAME}'")).replaces = "'${REPLACES}'"' \
${OPERATOR_PATH}/src/main/olm/channel.${RELEASE_CHANNEL}.yaml
fi

PRERELEASE_CHANNEL=$(echo "${PRERELEASE_VERSION}" | sed -E 's/([0-9]+)\.([0-9]+)\.[0-9]+(-snapshot)?/\1.\2.x/g')

if [ -f ${OPERATOR_PATH}/src/main/olm/channel.${PRERELEASE_CHANNEL}.yaml ] ; then
${YQ} -i 'del(.entries[] | select(.name == "'${PRERELEASE_CSV_NAME}'"))' \
${OPERATOR_PATH}/src/main/olm/channel.${PRERELEASE_CHANNEL}.yaml
fi
else
# Change the name of the entry to be the released version (e.g removing the -snapshot suffix)
${YQ} -i '(.entries[].name | select(. == "'${PRERELEASE_CSV_NAME}'")) = "'${RELEASE_CSV_NAME}'"' \
${OPERATOR_PATH}/src/main/olm/channel.${RELEASE_CHANNEL}.yaml
fi

# Create a file with a reference to the bundle image to be generated during the release
echo "image: ${IMAGE_NAME}:${VERSION}" > ${OPERATOR_PATH}/src/main/olm/bundles/${RELEASE_CSV_NAME}.yaml

if [ "${GIT_STAGE}" == "true" ] ; then
git add ${OPERATOR_PATH}/src/main/olm/channel.alpha.yaml ${OPERATOR_PATH}/src/main/olm/bundles/${RELEASE_CSV_NAME}.yaml
git add ${OPERATOR_PATH}/src/main/olm/channel.*.yaml ${OPERATOR_PATH}/src/main/olm/bundles/${RELEASE_CSV_NAME}.yaml
fi
fi
7 changes: 7 additions & 0 deletions operator/src/main/olm/channel.0.5.x.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
schema: olm.channel
name: 0.5.x
package: streamshub-console-operator
properties: []
entries:
- name: streamshub-console-operator.v0.5.0
12 changes: 12 additions & 0 deletions operator/src/main/olm/channel.0.6.x.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
schema: olm.channel
name: 0.6.x
package: streamshub-console-operator
properties: []
entries:
- name: streamshub-console-operator.v0.6.0
replaces: streamshub-console-operator.v0.5.0
- name: streamshub-console-operator.v0.6.1
replaces: streamshub-console-operator.v0.6.0
- name: streamshub-console-operator.v0.6.2-snapshot
replaces: streamshub-console-operator.v0.6.1

0 comments on commit 01292a8

Please sign in to comment.