diff --git a/operator/bin/release-prepare.sh b/operator/bin/release-prepare.sh index 9d5a1669f..fa1aa8094 100755 --- a/operator/bin/release-prepare.sh +++ b/operator/bin/release-prepare.sh @@ -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 @@ -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 diff --git a/operator/src/main/olm/channel.0.5.x.yaml b/operator/src/main/olm/channel.0.5.x.yaml new file mode 100644 index 000000000..976fa9283 --- /dev/null +++ b/operator/src/main/olm/channel.0.5.x.yaml @@ -0,0 +1,7 @@ +--- +schema: olm.channel +name: 0.5.x +package: streamshub-console-operator +properties: [] +entries: + - name: streamshub-console-operator.v0.5.0 diff --git a/operator/src/main/olm/channel.0.6.x.yaml b/operator/src/main/olm/channel.0.6.x.yaml new file mode 100644 index 000000000..44a3c99be --- /dev/null +++ b/operator/src/main/olm/channel.0.6.x.yaml @@ -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