From 52ffc3e7af1b2ee157beedcc4300f7ecbf548f5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Andr=C3=A9?= Date: Mon, 25 Aug 2025 16:07:19 +0200 Subject: [PATCH 1/4] bundle: get git tag more reliably --- hack/bundle.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hack/bundle.sh b/hack/bundle.sh index 9794385e9..dcc5f1180 100644 --- a/hack/bundle.sh +++ b/hack/bundle.sh @@ -2,7 +2,7 @@ REGISTRY=${REGISTRY:-quay.io/orc} IMAGE=${BASE_IMAGE:-openstack-resource-controller} -TAG=${BASE_IMAGE:-$(git describe --abbrev=0)} +TAG=${BASE_IMAGE:-$(git describe --abbrev=0 --tags)} IMG=${REGISTRY}/${IMAGE}:${TAG} # Update config/manifests/bases/orc.clusterserviceversion.yaml if needed From 34d5f7a38dbf8b01793dfdb9bb2eef878f08b57b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Andr=C3=A9?= Date: Mon, 25 Aug 2025 16:07:53 +0200 Subject: [PATCH 2/4] bundle: use latest git tag as the CSV version This is the version visible to the users. We're going to build the bundle each time we tag the repo, so it makes sense to align the CSV version to the latest git tag. --- hack/bundle.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hack/bundle.sh b/hack/bundle.sh index dcc5f1180..7f189b410 100644 --- a/hack/bundle.sh +++ b/hack/bundle.sh @@ -14,6 +14,9 @@ mkdir "${TMP_OVERLAY}" pushd "${TMP_OVERLAY}" || exit kustomize create --resources ../manifests kustomize edit set image controller="${IMG}" + +kustomize edit add patch --kind ClusterServiceVersion --name "orc.*" --patch '[{"op": "replace", "path": "/spec/version", "value": "'$TAG'"}]' +kustomize edit add patch --kind ClusterServiceVersion --name "orc.*" --patch '[{"op": "replace", "path": "/metadata/name", "value": "orc.'$TAG'"}]' popd || exit # Generate bundle and bundle.Dockerfile From 9cde697d5cf376b18a7a34335f656327e036cf0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Andr=C3=A9?= Date: Mon, 25 Aug 2025 16:10:43 +0200 Subject: [PATCH 3/4] Make: add targets to install operator-sdk and build the bundle image --- Makefile | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Makefile b/Makefile index 4cfc0d564..c48c411c6 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,6 @@ # Image URL to use all building/pushing image targets IMG ?= controller:latest +BUNDLE_IMG ?= bundle:latest # ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary. ENVTEST_K8S_VERSION = 1.29.0 TRIVY_VERSION = 0.49.1 @@ -207,6 +208,11 @@ build-installer: manifests generate kustomize ## Generate a consolidated YAML wi $(MAKE) custom-deploy IMG=${IMG} $(KUSTOMIZE) build $(CUSTOMDEPLOY) > dist/install.yaml +.PHONY: build-bundle-image +build-bundle-image: kustomize operator-sdk + bash hack/bundle.sh + $(CONTAINER_TOOL) build -f bundle.Dockerfile -t ${BUNDLE_IMG} . + ##@ Deployment ifndef ignore-not-found @@ -299,6 +305,7 @@ GOLANGCI_KAL = $(LOCALBIN)/golangci-kube-api-linter MOCKGEN = $(LOCALBIN)/mockgen KUTTL = $(LOCALBIN)/kubectl-kuttl GOVULNCHECK = $(LOCALBIN)/govulncheck +OPERATOR_SDK = $(LOCALBIN)/operator-sdk ## Tool Versions KUSTOMIZE_VERSION ?= v5.6.0 @@ -309,6 +316,7 @@ KAL_VERSION ?= v0.0.0-20250531094218-f86bf7bd4b19 MOCKGEN_VERSION ?= v0.5.0 KUTTL_VERSION ?= v0.22.0 GOVULNCHECK_VERSION ?= v1.1.4 +OPERATOR_SDK_VERSION ?= v1.41.1 .PHONY: kustomize kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary. @@ -363,6 +371,11 @@ govulncheck: $(GOVULNCHECK) ## Download govulncheck locally if necessary. $(GOVULNCHECK): $(LOCALBIN) $(call go-install-tool,$(GOVULNCHECK),golang.org/x/vuln/cmd/govulncheck,$(GOVULNCHECK_VERSION)) +.PHONY: operator-sdk +operator-sdk: $(OPERATOR_SDK) ## Download operator-sdk locally if necessary. +$(OPERATOR_SDK): $(LOCALBIN) + $(call go-install-tool,$(OPERATOR_SDK),github.com/operator-framework/operator-sdk/cmd/operator-sdk,$(OPERATOR_SDK_VERSION)) + # go-install-tool will 'go install' any package with custom target and name of binary, if it doesn't exist # $1 - target path with name of binary # $2 - package url which can be installed From 40a7a91d270afba719b17ca896419ce75b8030dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Andr=C3=A9?= Date: Mon, 25 Aug 2025 16:14:05 +0200 Subject: [PATCH 4/4] Workflow: Build and publish bundle image on new git tag --- .github/workflows/release_image.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/release_image.yaml b/.github/workflows/release_image.yaml index e335d25cd..41747aaa7 100644 --- a/.github/workflows/release_image.yaml +++ b/.github/workflows/release_image.yaml @@ -10,6 +10,7 @@ permissions: env: image_tag: quay.io/orc/openstack-resource-controller:${GITHUB_REF_NAME} + bundle_image_tag: quay.io/orc/openstack-resource-controller-bundle:${GITHUB_REF_NAME} jobs: push: @@ -24,7 +25,11 @@ jobs: fetch-tags: true - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 + - name: Install build dependencies + run: sudo apt-get install -y libgpgme-dev - run: | docker login -u="${{ secrets.QUAY_USERNAME }}" -p="${{ secrets.QUAY_TOKEN }}" quay.io make docker-buildx IMG=${{ env.image_tag }} + make build-bundle-image BUNDLE_IMG=${{ env.bundle_image_tag }} + make docker-push IMG=${{ env.bundle_image_tag }}