diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 83bb5d405..aaad2ecac 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -93,7 +93,8 @@ jobs: # ==================== Operator-Bundle ==================== - name: Modify Bundle CSV Metadata - run: ./operator/bin/modify-bundle-metadata.sh + working-directory: target/checkout + run: ./operator/bin/modify-bundle-metadata.sh "VERSION=${{steps.metadata.outputs.current-version}}" "SKIP_RANGE=>=0.0.1 <${{steps.metadata.outputs.current-version}}" - name: Build and Push Operator Bundle Image uses: docker/build-push-action@v6 @@ -115,8 +116,7 @@ jobs: chmod +x opm sudo cp -v opm /usr/bin/ rm -vf opm - VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout | tr '[:upper:]' '[:lower:]') - operator/bin/generate-catalog.sh ${VERSION} + operator/bin/generate-catalog.sh ${{steps.metadata.outputs.current-version}} - name: Build and Push Operator Catalog Image uses: docker/build-push-action@v6 diff --git a/.github/workflows/snapshot.yml b/.github/workflows/snapshot.yml index 7c3d15d07..fc204737b 100644 --- a/.github/workflows/snapshot.yml +++ b/.github/workflows/snapshot.yml @@ -98,7 +98,7 @@ jobs: # ==================== Operator-Bundle ==================== - name: Modify Bundle CSV Metadata - run: ./operator/bin/modify-bundle-metadata.sh "SKIP_RANGE=>=0.0.1 <${{ env.NEXT_VERSION }}" + run: ./operator/bin/modify-bundle-metadata.sh "VERSION=${{ env.NEXT_VERSION }}" "SKIP_RANGE=>=0.0.1 <${{ env.NEXT_VERSION }}" - name: Build and Push Operator Bundle Image uses: docker/build-push-action@v6 diff --git a/Makefile b/Makefile index 355a3cbb6..413772f9f 100644 --- a/Makefile +++ b/Makefile @@ -6,6 +6,7 @@ include *compose.env IMAGE_REGISTRY ?= quay.io IMAGE_GROUP ?= streamshub VERSION ?= $(shell mvn help:evaluate -Dexpression=project.version -q -DforceStdout | tr '[:upper:]' '[:lower:]') +CSV_VERSION ?= $(VERSION) CONSOLE_API_IMAGE ?= $(IMAGE_REGISTRY)/$(IMAGE_GROUP)/console-api:$(VERSION) CONSOLE_UI_IMAGE ?= $(IMAGE_REGISTRY)/$(IMAGE_GROUP)/console-ui:$(VERSION) @@ -34,8 +35,8 @@ container-image-api-push: container-image-api container-image-operator: mvn package -am -pl operator -Pcontainer-image -DskipTests -Dquarkus.container-image.image=$(CONSOLE_OPERATOR_IMAGE) - operator/bin/modify-bundle-metadata.sh SKOPEO_TRANSPORT=$(SKOPEO_TRANSPORT) - operator/bin/generate-catalog.sh $(VERSION) + operator/bin/modify-bundle-metadata.sh "VERSION=$(CSV_VERSION)" "SKIP_RANGE=$(SKIP_RANGE)" "SKOPEO_TRANSPORT=$(SKOPEO_TRANSPORT)" + operator/bin/generate-catalog.sh $(CSV_VERSION) $(CONTAINER_RUNTIME) build --platform=$(ARCH) -t $(CONSOLE_OPERATOR_BUNDLE_IMAGE) -f operator/target/bundle/console-operator/bundle.Dockerfile $(CONTAINER_RUNTIME) build --platform=$(ARCH) -t $(CONSOLE_OPERATOR_CATALOG_IMAGE) -f operator/target/catalog.Dockerfile diff --git a/operator/bin/generate-catalog.sh b/operator/bin/generate-catalog.sh index 41b0a0a6a..fa3b07a81 100755 --- a/operator/bin/generate-catalog.sh +++ b/operator/bin/generate-catalog.sh @@ -1,9 +1,11 @@ #!/bin/bash SCRIPT_PATH="$(cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P)" -source ${SCRIPT_PATH}/common.sh + export VERSION="${1}" +source ${SCRIPT_PATH}/common.sh + echo "[INFO] Generate catalog" rm -rvf ${CATALOG_PATH} ${CATALOG_PATH}.Dockerfile diff --git a/operator/bin/modify-bundle-metadata.sh b/operator/bin/modify-bundle-metadata.sh index 0ea28546d..a101a62ec 100755 --- a/operator/bin/modify-bundle-metadata.sh +++ b/operator/bin/modify-bundle-metadata.sh @@ -1,8 +1,8 @@ #!/bin/bash SCRIPT_PATH="$(cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P)" -source ${SCRIPT_PATH}/common.sh +VERSION="" SKIP_RANGE="" SKOPEO_TRANSPORT="docker://" @@ -12,19 +12,27 @@ do VALUE=$(echo "$ARGUMENT" | sed 's/^[^=]*=//') case "$KEY" in - SKIP_RANGE) SKIP_RANGE=${VALUE};; - ORIGINAL_OPERATOR_NAME) ORIGINAL_OPERATOR_NAME=${VALUE};; - SKOPEO_TRANSPORT) SKOPEO_TRANSPORT=${VALUE};; + VERSION) VERSION=${VALUE};; + SKIP_RANGE) SKIP_RANGE=${VALUE};; + ORIGINAL_OPERATOR_NAME) ORIGINAL_OPERATOR_NAME=${VALUE};; + SKOPEO_TRANSPORT) SKOPEO_TRANSPORT=${VALUE};; *) esac done +source ${SCRIPT_PATH}/common.sh + api_name="console-api" ui_name="console-ui" operator_name="console-operator" echo "[INFO] Modify values and replace placeholders in ${CSV_FILE_PATH}" +if [[ -n "$VERSION" ]]; then + echo "[DEBUG] Setting version = \"${VERSION}\"" + ${YQ} eval -o yaml -i ".spec.version = \"${VERSION}\"" "${CSV_FILE_PATH}" +fi + # Delete any namespaces set on the CSV deployment(s), possibly added by `quarkus.kubernetes.namespace` ${YQ} eval -o yaml -i 'del(.spec.install.spec.deployments[0].spec.template.metadata.namespace)' "${CSV_FILE_PATH}" @@ -69,6 +77,10 @@ ${YQ} eval -o yaml -i ".spec.install.spec.deployments[0].spec.template.spec.cont ${YQ} eval -o yaml -i ".spec.install.spec.deployments[0].spec.template.spec.serviceAccountName = \"${OPERATOR_NAME}\"" "${CSV_FILE_PATH}" ${YQ} eval -o yaml -i ".spec.install.spec.clusterPermissions.[].serviceAccountName = \"${OPERATOR_NAME}\"" "${CSV_FILE_PATH}" +echo "[DEBUG] Updating package name annotation and image label to ${OPERATOR_NAME}" +${YQ} eval -o yaml -i ".annotations.[\"operators.operatorframework.io.bundle.package.v1\"] = \"${OPERATOR_NAME}\"" "${BUNDLE_PATH}/metadata/annotations.yaml" +sed -i 's/'${ORIGINAL_OPERATOR_NAME}'/'${OPERATOR_NAME}'/' "${BUNDLE_PATH}/bundle.Dockerfile" + # Add Env for operator deployment that references API and UI images with digest instead of tag echo "[DEBUG] Add UI and API images to CSV"