diff --git a/.github/workflows/operatorhub.yaml b/.github/workflows/operatorhub.yaml index 04e26af62..110af2ec4 100644 --- a/.github/workflows/operatorhub.yaml +++ b/.github/workflows/operatorhub.yaml @@ -15,8 +15,6 @@ jobs: update: name: Publish new OperatorHub release runs-on: ubuntu-latest - env: - CHANNEL: ${{ startsWith(github.event.workflow_run.head_branch, 'release') && 'stable' || 'beta' }} if: ${{ (github.event.workflow_run.conclusion == 'success' && ! contains(github.event.workflow_run.head_branch, '-')) || github.event_name == 'workflow_dispatch' && github.event.workflow_run.release != 'prereleased' }} strategy: matrix: @@ -60,6 +58,11 @@ jobs: run_id: ${{ github.event.workflow_run.id }} path: bundle + - name: Set channel + run: | + echo "CHANNEL=$(cat bundle/CHANNEL 2>/dev/null || echo beta)" >> $GITHUB_ENV + rm -f bundle/CHANNEL + - name: Add operatorhub bundle id: update run: | @@ -79,19 +82,26 @@ jobs: } | sort -V | grep -B1 "^${NEW_VERSION}$" | grep -v "^${NEW_VERSION}$" ) export OLD_ENTRY="${OPERATOR_NAME}.v${OLD_VERSION}" + export MANIFEST_PATH=bundle/${NEW_VERSION}/manifests/victoriametrics-operator.clusterserviceversion.yaml if [ ! -z $OLD_VERSION ]; then - export MANIFEST_PATH=bundle/${NEW_VERSION}/manifests/victoriametrics-operator.clusterserviceversion.yaml yq -i '.spec.replaces = "victoriametrics-operator.v" + strenv(OLD_VERSION)' $MANIFEST_PATH fi + if [ ! -z $MANIFEST_PATH ]; then + yq -i '.metadata["operators.operatorframework.io.bundle.channel.default.v1"] = strenv(CHANNEL)' $MANIFEST_PATH + yq -i '.metadata["operators.operatorframework.io.bundle.channels.v1"] = strenv(CHANNEL)' $MANIFEST_PATH + yq -i '.annotations["operators.operatorframework.io.bundle.channel.default.v1"] = strenv(CHANNEL)' bundle/${NEW_VERSION}/metadata/annotations.yaml + yq -i '.annotations["operators.operatorframework.io.bundle.channels.v1"] = strenv(CHANNEL)' bundle/${NEW_VERSION}/metadata/annotations.yaml + fi + mv bundle/${NEW_VERSION} ${OPERATOR_DIR}/ if [ -f ${OPERATOR_DIR}/Makefile ]; then yq -n '.catalog_templates = []' > ${OPERATOR_DIR}/${NEW_VERSION}/release-config.yaml for TEMPLATE in ${OPERATOR_DIR}/catalog-templates/*.yaml; do export TPL=$(basename ${TEMPLATE}) if [ "$CHANNEL" = "stable" ] && ! yq -e '.entries[] | select(.schema == "olm.channel" and .name == "stable")' "$TEMPLATE" > /dev/null 2>&1 && [ -n "$OLD_VERSION" ]; then - yq -i '.catalog_templates += [{"template_name": strenv(TPL), "channels": ["stable","beta"], "replaces": strenv(OLD_ENTRY)}]' ${OPERATOR_DIR}/${NEW_VERSION}/release-config.yaml + yq -i '.catalog_templates += [{"template_name": strenv(TPL), "channels": ["stable"], "replaces": strenv(OLD_ENTRY)}]' ${OPERATOR_DIR}/${NEW_VERSION}/release-config.yaml elif [ -n "$OLD_VERSION" ]; then yq -i '.catalog_templates += [{"template_name": strenv(TPL), "channels": [strenv(CHANNEL)], "replaces": strenv(OLD_ENTRY)}]' ${OPERATOR_DIR}/${NEW_VERSION}/release-config.yaml else diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 95d46810d..967f28c01 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -48,6 +48,11 @@ jobs: TAG=${TAG} make publish TAG=${TAG} make sign TAG=${TAG} REGISTRY=quay.io make olm + if [[ "${{ github.event.release.target_commitish }}" == release-* ]]; then + echo "stable" > bundle/CHANNEL + else + echo "beta" > bundle/CHANNEL + fi gh release upload ${{github.event.release.tag_name}} ./dist/install-no-webhook.yaml#install-no-webhook.yaml --clobber || echo "fix me NOT enough security permissions" gh release upload ${{github.event.release.tag_name}} ./dist/install-with-webhook.yaml#install-with-webhook.yaml --clobber || echo "fix me NOT enough security permissions" gh release upload ${{github.event.release.tag_name}} ./config/crd/overlay/crd.yaml#crd.yaml --clobber || echo "fix me NOT enough security permissions"