From e50d34ace1f05c1c6bec82f5f2604b2457ef6076 Mon Sep 17 00:00:00 2001 From: dd di cesare Date: Wed, 6 Nov 2024 17:14:46 +0100 Subject: [PATCH 1/3] [make] unifying opm builder, base image and tool Signed-off-by: dd di cesare --- Makefile | 7 ++++--- make/catalog.mk | 4 +++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 94f30a2e..6b8a9720 100644 --- a/Makefile +++ b/Makefile @@ -138,14 +138,15 @@ $(YQ): .PHONY: yq yq: $(YQ) ## Download yq locally if necessary. +ARCH ?= $(shell go env GOARCH) OPM = $(PROJECT_DIR)/bin/opm -OPM_VERSION = v1.26.2 +OPM_VERSION ?= 1.48.0 $(OPM): @{ \ set -e ;\ mkdir -p $(dir $(OPM)) ;\ - OS=$(shell go env GOOS) && ARCH=$(shell go env GOARCH) && \ - curl -sSLo $(OPM) https://github.com/operator-framework/operator-registry/releases/download/$(OPM_VERSION)/$${OS}-$${ARCH}-opm ;\ + OS=$(shell go env GOOS) && \ + curl -sSLo $(OPM) https://github.com/operator-framework/operator-registry/releases/download/v$(OPM_VERSION)/$${OS}-$(ARCH)-opm ;\ chmod +x $(OPM) ;\ } diff --git a/make/catalog.mk b/make/catalog.mk index fe9e0ef4..5e177cbc 100644 --- a/make/catalog.mk +++ b/make/catalog.mk @@ -6,9 +6,11 @@ CATALOG_IMG ?= $(IMAGE_TAG_BASE)-catalog:$(IMAGE_TAG) CATALOG_FILE = $(PROJECT_DIR)/catalog/authorino-operator-catalog/operator.yaml CATALOG_DOCKERFILE = $(PROJECT_DIR)/catalog/authorino-operator-catalog.Dockerfile +OPM_DOCKERFILE_TAG ?= v$(OPM_VERSION)-$(ARCH) + $(CATALOG_DOCKERFILE): $(OPM) -mkdir -p $(PROJECT_DIR)/catalog/authorino-operator-catalog - cd $(PROJECT_DIR)/catalog && $(OPM) generate dockerfile authorino-operator-catalog + cd $(PROJECT_DIR)/catalog && $(OPM) generate dockerfile authorino-operator-catalog -i "quay.io/operator-framework/opm:${OPM_DOCKERFILE_TAG}" -b "quay.io/operator-framework/opm:${OPM_DOCKERFILE_TAG}" catalog-dockerfile: $(CATALOG_DOCKERFILE) ## Generate catalog dockerfile. $(CATALOG_FILE): $(OPM) $(YQ) From 8dcd1c3f78f5db0af4903359d52a8dbea409a7df Mon Sep 17 00:00:00 2001 From: dd di cesare Date: Wed, 6 Nov 2024 17:15:48 +0100 Subject: [PATCH 2/3] [workflow] Building multiarch catalogs with uraimo/run-on-arch-action@v2 Signed-off-by: dd di cesare --- .github/workflows/build-images.yaml | 61 +++++++++++++++++++---------- 1 file changed, 40 insertions(+), 21 deletions(-) diff --git a/.github/workflows/build-images.yaml b/.github/workflows/build-images.yaml index 05294987..4ac6b60b 100644 --- a/.github/workflows/build-images.yaml +++ b/.github/workflows/build-images.yaml @@ -159,9 +159,12 @@ jobs: run: echo "Image pushed to ${{ steps.push-to-quay.outputs.registry-paths }}" build-catalog: - name: Build and push catalog image + name: Build and push catalog image for arch ${{ matrix.arch }} needs: [build, build-bundle] runs-on: ubuntu-20.04 + strategy: + matrix: + arch: [ amd64, arm64, ppc64le, s390x ] if: github.ref_name == 'main' || startsWith(github.ref, 'refs/tags/v') # We cannot use `env.MAIN_BRANCH_NAME` because `env` context is not available to `job.if`. See https://docs.github.com/en/actions/learn-github-actions/contexts#context-availability steps: - name: Set up Go 1.21.x @@ -192,27 +195,42 @@ jobs: else echo "VERSION=${{ github.sha }}" >> $GITHUB_ENV fi - - name: Install qemu dependency - run: | - sudo apt-get update - sudo apt-get install -y qemu-user-static - - name: Run make catalog (main) + - name: Run make catalog (main) for arch ${{ matrix.arch }} + uses: uraimo/run-on-arch-action@v2 if: ${{ github.ref_name == env.MAIN_BRANCH_NAME }} - run: | - make catalog \ - REGISTRY=${{ env.IMG_REGISTRY_HOST }} ORG=${{ env.IMG_REGISTRY_ORG }} \ - VERSION=${{ env.VERSION }} \ - IMAGE_TAG=${{ github.sha }} \ - AUTHORINO_VERSION=${{ env.LATEST_AUTHORINO_GITREF }} \ - CHANNELS=${{ inputs.channels }} - - name: Run make catalog (release) + with: + arch: ${{ matrix.arch }} + distro: ubuntu22.04 + githubToken: ${{ github.token }} + install: | + sudo apt-get update + sudo apt-get install -y qemu-user-static + run: | + make catalog \ + REGISTRY=${{ env.IMG_REGISTRY_HOST }} ORG=${{ env.IMG_REGISTRY_ORG }} \ + VERSION=${{ env.VERSION }} \ + IMAGE_TAG=${{ github.sha }} \ + AUTHORINO_VERSION=${{ env.LATEST_AUTHORINO_GITREF }} \ + CHANNELS=${{ inputs.channels }} \ + ARCH=${{ matrix.arch }} + + - name: Run make catalog (release) for arch ${{ matrix.arch }} + uses: uraimo/run-on-arch-action@v2 if: ${{ github.ref_name != env.MAIN_BRANCH_NAME }} - run: | - make catalog \ - REGISTRY=${{ env.IMG_REGISTRY_HOST }} ORG=${{ env.IMG_REGISTRY_ORG }} \ - VERSION=${{ env.VERSION }} \ - AUTHORINO_VERSION=${{ github.event.inputs.authorinoVersion }} \ - CHANNELS=${{ inputs.channels }} + with: + arch: ${{ matrix.arch }} + distro: ubuntu22.04 + githubToken: ${{ github.token }} + install: | + sudo apt-get update + sudo apt-get install -y qemu-user-static + run: | + make catalog \ + REGISTRY=${{ env.IMG_REGISTRY_HOST }} ORG=${{ env.IMG_REGISTRY_ORG }} \ + VERSION=${{ env.VERSION }} \ + AUTHORINO_VERSION=${{ env.LATEST_AUTHORINO_GITREF }} \ + CHANNELS=${{ inputs.channels }} \ + ARCH=${{ matrix.arch }} - name: Git diff run: git diff - name: Build Image @@ -221,7 +239,8 @@ jobs: with: image: ${{ env.OPERATOR_NAME }}-catalog tags: ${{ env.IMG_TAGS }} - platforms: linux/amd64,linux/arm64 + platform: ${{ matrix.arch }} + arch: ${{ matrix.arch }} context: ./catalog dockerfiles: | ./catalog/${{ env.OPERATOR_NAME }}-catalog.Dockerfile From f7a9a75b5e9ef03d20a8defbfd2e44e205b64453 Mon Sep 17 00:00:00 2001 From: dd di cesare Date: Wed, 6 Nov 2024 17:22:29 +0100 Subject: [PATCH 3/3] [tmp] forcing builds Signed-off-by: dd di cesare --- .github/workflows/build-images.yaml | 71 +---------------------------- 1 file changed, 1 insertion(+), 70 deletions(-) diff --git a/.github/workflows/build-images.yaml b/.github/workflows/build-images.yaml index 4ac6b60b..0168bd04 100644 --- a/.github/workflows/build-images.yaml +++ b/.github/workflows/build-images.yaml @@ -26,69 +26,9 @@ env: LATEST_AUTHORINO_GITREF: ${{ vars.AUTHORINO_SHA != '' && vars.AUTHORINO_SHA || 'latest' }} jobs: - build: - name: Build and push image - runs-on: ubuntu-20.04 - steps: - - name: Check out code - uses: actions/checkout@v3 - - name: Add latest tag - if: ${{ github.ref_name == env.MAIN_BRANCH_NAME }} - id: add-latest-tag - run: | - echo "IMG_TAGS=latest ${{ env.IMG_TAGS }}" >> $GITHUB_ENV - - name: Add branch tag - if: ${{ github.ref_name != env.MAIN_BRANCH_NAME }} - id: add-branch-tag - run: | - echo "IMG_TAGS=${GITHUB_REF_NAME/\//-} ${{ env.IMG_TAGS }}" >> $GITHUB_ENV - - name: Set Operator version - id: operator-version - run: | - if [[ ${GITHUB_REF_NAME/\//-} =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-.+)?$ ]]; then - echo "VERSION=${GITHUB_REF_NAME/\//-}" >> $GITHUB_ENV - else - echo "VERSION=${{ github.sha }}" >> $GITHUB_ENV - fi - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - name: Install yq dependency - run: make yq - - name: Set default authorino image - run: | - echo "DEFAULT_AUTHORINO_IMAGE=$(./bin/yq e -e '.config.authorinoImage' ${{ env.BUILD_CONFIG_FILE }} || echo ${{ env.IMG_REGISTRY_HOST }}/${{ env.IMG_REGISTRY_ORG }}/authorino:${{ env.LATEST_AUTHORINO_GITREF }})" >> $GITHUB_ENV - - name: Build Image - id: build-image - uses: redhat-actions/buildah-build@v2 - with: - image: ${{ env.OPERATOR_NAME }} - tags: ${{ env.IMG_TAGS }} - platforms: linux/amd64,linux/arm64,linux/s390x,linux/ppc64le - build-args: | - OPERATOR_VERSION=${{ env.VERSION }} - GIT_SHA=${{ github.sha }} - DIRTY=false - DEFAULT_AUTHORINO_IMAGE=${{ env.DEFAULT_AUTHORINO_IMAGE }} - containerfiles: | - ./Dockerfile - - name: Push Image - if: ${{ !env.ACT }} - id: push-to-quay - uses: redhat-actions/push-to-registry@v2 - with: - image: ${{ steps.build-image.outputs.image }} - tags: ${{ steps.build-image.outputs.tags }} - registry: ${{ env.IMG_REGISTRY_HOST }}/${{ env.IMG_REGISTRY_ORG }} - username: ${{ secrets.IMG_REGISTRY_USERNAME }} - password: ${{ secrets.IMG_REGISTRY_TOKEN }} - - name: Print Image URL - run: echo "Image pushed to ${{ steps.push-to-quay.outputs.registry-paths }}" - build-bundle: - needs: build name: Build and push bundle image runs-on: ubuntu-20.04 - if: github.ref_name == 'main' || startsWith(github.ref, 'refs/tags/v') # We cannot use `env.MAIN_BRANCH_NAME` because `env` context is not available to `job.if`. See https://docs.github.com/en/actions/learn-github-actions/contexts#context-availability steps: - name: Set up Go 1.21.x uses: actions/setup-go@v4 @@ -128,12 +68,6 @@ jobs: run: make bundle REGISTRY=${{ env.IMG_REGISTRY_HOST }} ORG=${{ env.IMG_REGISTRY_ORG }} VERSION=${{env.VERSION}} AUTHORINO_VERSION=${{ github.event.inputs.authorinoVersion }} CHANNELS=${{ github.event.inputs.channels }} DEFAULT_CHANNEL=stable - name: Git diff run: git diff - - name: Verify manifests and bundle (main) - if: github.ref_name == env.MAIN_BRANCH_NAME - run: make verify-manifests verify-bundle REGISTRY=${{ env.IMG_REGISTRY_HOST }} ORG=${{ env.IMG_REGISTRY_ORG }} IMAGE_TAG=${{ github.sha }} AUTHORINO_VERSION=${{ env.LATEST_AUTHORINO_GITREF }} - - name: Verify manifests and bundle (release) - if: ${{ github.ref_name != env.MAIN_BRANCH_NAME }} - run: make verify-manifests verify-bundle REGISTRY=${{ env.IMG_REGISTRY_HOST }} ORG=${{ env.IMG_REGISTRY_ORG }} VERSION=${{env.VERSION}} AUTHORINO_VERSION=${{ github.event.inputs.authorinoVersion }} CHANNELS=${{ github.event.inputs.channels }} DEFAULT_CHANNEL=stable - name: Build Image id: build-image uses: redhat-actions/buildah-build@v2 @@ -160,12 +94,11 @@ jobs: build-catalog: name: Build and push catalog image for arch ${{ matrix.arch }} - needs: [build, build-bundle] + needs: [build-bundle] runs-on: ubuntu-20.04 strategy: matrix: arch: [ amd64, arm64, ppc64le, s390x ] - if: github.ref_name == 'main' || startsWith(github.ref, 'refs/tags/v') # We cannot use `env.MAIN_BRANCH_NAME` because `env` context is not available to `job.if`. See https://docs.github.com/en/actions/learn-github-actions/contexts#context-availability steps: - name: Set up Go 1.21.x uses: actions/setup-go@v4 @@ -200,7 +133,6 @@ jobs: if: ${{ github.ref_name == env.MAIN_BRANCH_NAME }} with: arch: ${{ matrix.arch }} - distro: ubuntu22.04 githubToken: ${{ github.token }} install: | sudo apt-get update @@ -219,7 +151,6 @@ jobs: if: ${{ github.ref_name != env.MAIN_BRANCH_NAME }} with: arch: ${{ matrix.arch }} - distro: ubuntu22.04 githubToken: ${{ github.token }} install: | sudo apt-get update