Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run on arch alt #225

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
128 changes: 39 additions & 89 deletions .github/workflows/build-images.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -159,10 +93,12 @@ jobs:
run: echo "Image pushed to ${{ steps.push-to-quay.outputs.registry-paths }}"

build-catalog:
name: Build and push catalog image
needs: [build, build-bundle]
name: Build and push catalog image for arch ${{ matrix.arch }}
needs: [build-bundle]
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
strategy:
matrix:
arch: [ amd64, arm64, ppc64le, s390x ]
steps:
- name: Set up Go 1.21.x
uses: actions/setup-go@v4
Expand Down Expand Up @@ -192,27 +128,40 @@ 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 }}
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 }}
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
Expand All @@ -221,7 +170,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
Expand Down
7 changes: 4 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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) ;\
}

Expand Down
4 changes: 3 additions & 1 deletion make/catalog.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading