diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 6e8848f31..946858dd6 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -438,9 +438,15 @@ jobs: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} + - name: Set environment variables + id: vars + run: | + echo "COMMIT_SHORT_SHA=${GITHUB_SHA:0:8}" >> $GITHUB_ENV - name: Build bundle-image env: BUNDLE_IMAGE: "ghcr.io/nvidia/gpu-operator/gpu-operator-bundle:${{ github.ref_name }}-latest" + BUNDLE_IMAGE_TAG: "ghcr.io/nvidia/gpu-operator/gpu-operator-bundle:${{ env.COMMIT_SHORT_SHA }}" + OPERATOR_IMAGE_TAG: "ghcr.io/nvidia/gpu-operator:${{ env.COMMIT_SHORT_SHA }}" VERSION: "" DEFAULT_CHANNEL: "stable" CHANNELS: "stable" diff --git a/Makefile b/Makefile index ed3b063a1..497dceb61 100644 --- a/Makefile +++ b/Makefile @@ -60,6 +60,9 @@ BUNDLE_METADATA_OPTS ?= $(BUNDLE_CHANNELS) $(BUNDLE_DEFAULT_CHANNEL) # BUNDLE_IMAGE defines the image:tag used for the bundle. # You can use it as an arg. (E.g make bundle-build BUNDLE_IMAGE=/:) BUNDLE_IMAGE ?= gpu-operator-bundle:$(VERSION) +BUNDLE_IMAGE_TAG ?= gpu-operator-bundle:$(VERSION) +BUNDLE_CSV_FILE ?= bundle/manifests/gpu-operator-certified.clusterserviceversion.yaml +OPERATOR_IMAGE_TAG ?= gpu-operator:$(VERSION) # Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set) ifeq (,$(shell go env GOBIN)) @@ -126,16 +129,23 @@ bundle: manifests install-tools $(KUSTOMIZE) build config/manifests | operator-sdk generate bundle -q --overwrite --version $(VERSION) $(BUNDLE_METADATA_OPTS) operator-sdk bundle validate ./bundle +# update the bundle image tag in csv file +update-bundle-csv: + @echo "Updating GPU operator image in $(BUNDLE_CSV_FILE) to $(OPERATOR_IMAGE_TAG)" + @sed -i -e 's|gpu-operator:[^ " ]*|$(OPERATOR_IMAGE_TAG)|g' $(BUNDLE_CSV_FILE) + @echo "Bundle CSV updated successfully" + # Build the bundle image. -build-bundle-image: +build-bundle-image: update-bundle-csv $(DOCKER) build \ --build-arg DEFAULT_CHANNEL=$(DEFAULT_CHANNEL) \ --build-arg GIT_COMMIT=$(GIT_COMMIT) \ - -f docker/bundle.Dockerfile -t $(BUNDLE_IMAGE) . + -f docker/bundle.Dockerfile -t $(BUNDLE_IMAGE) -t $(BUNDLE_IMAGE_TAG) . # Push the bundle image. push-bundle-image: build-bundle-image $(DOCKER) push $(BUNDLE_IMAGE) + $(DOCKER) push $(BUNDLE_IMAGE_TAG) # Define local and dockerized golang targets