From ffe4e5b17ca91066d4a6c04c847b81b8d8bbd1b2 Mon Sep 17 00:00:00 2001 From: Kevin Date: Wed, 24 May 2023 17:47:00 -0400 Subject: [PATCH 1/2] add new github action which tags and builds a new operator Signed-off-by: Kevin --- .github/workflows/tag-and-build.yml | 70 +++++++++++++++++++++++++++++ Makefile | 7 ++- 2 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/tag-and-build.yml diff --git a/.github/workflows/tag-and-build.yml b/.github/workflows/tag-and-build.yml new file mode 100644 index 000000000..38fd559e4 --- /dev/null +++ b/.github/workflows/tag-and-build.yml @@ -0,0 +1,70 @@ +# This workflow will build the CodeFlare Operator image and push it to the project-codeflare image registry + +name: Tag and Release +on: + workflow_dispatch: + inputs: + version: + description: 'Tag to be used for operator image' + required: true + default: '0.0.0-dev' + replaces: + description: 'The previous semantic version that this tag replaces.' + required: true + default: '0.0.0-dev' + +jobs: + push: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Activate cache + uses: actions/cache@v2 + with: + path: /cache + key: ${{ runner.os }}-cache-${{ hashFiles('**/go.sum', '.pre-commit-config.yaml') }} + + - name: Create tag + uses: actions/github-script@v6 + with: + script: | + github.rest.git.createRef({ + owner: context.repo.owner, + repo: context.repo.repo, + ref: 'refs/tags/${{ github.event.inputs.version }}', + sha: context.sha + }) + + - name: Install operator-sdk + run: make install-operator-sdk + + - name: Login to Quay.io + uses: redhat-actions/podman-login@v1 + with: + username: ${{ secrets.QUAY_ID }} + password: ${{ secrets.QUAY_TOKEN }} + registry: quay.io + + - name: Login to Red Hat Registry + uses: redhat-actions/podman-login@v1 + with: + username: ${{ secrets.RH_REG_ID }} + password: ${{ secrets.RH_REG_TOKEN }} + registry: registry.redhat.io + + - name: Image Build + run: | + make build + make bundle + make image-build -e IMG=quay.io/project-codeflare/codeflare-operator:${SOURCE_TAG} + podman tag quay.io/project-codeflare/codeflare-operator:${SOURCE_TAG} quay.io/project-codeflare/codeflare-operator:latest + env: + SOURCE_TAG: ${{ github.event.inputs.version }} + + - name: Image Push + run: | + make image-push -e IMG=quay.io/project-codeflare/codeflare-operator:${SOURCE_TAG} + make image-push -e IMG=quay.io/project-codeflare/codeflare-operator:latest + env: + SOURCE_TAG: ${{ github.event.inputs.version }} diff --git a/Makefile b/Makefile index 57e36fc93..436b7fe89 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,11 @@ # To re-generate a bundle for another specific version without changing the standard setup, you can: # - use the VERSION as arg of the bundle target (e.g make bundle VERSION=0.0.2) # - use environment variables to overwrite this value (e.g export VERSION=0.0.2) -VERSION ?= 0.0.2 +# best if we could detect this. If we cannot, we need to document it somewhere. +# then we can add a patch in the `PHONY: bundle` + +PREVIOUS_VERSION ?= 0.0.3 +VERSION ?= 0.0.3-dev # CHANNELS define the bundle channels used in the bundle. # Add a new line here if you would like to change its default config. (E.g CHANNELS = "candidate,fast,stable") @@ -193,6 +197,7 @@ bundle: manifests kustomize install-operator-sdk ## Generate bundle manifests an $(OPERATOR_SDK) generate kustomize manifests -q cd config/manager && $(KUSTOMIZE) edit set image controller=$(IMG) cd config/manifests && $(KUSTOMIZE) edit add patch --patch '[{"op":"add", "path":"/metadata/annotations/containerImage", "value": "$(IMG)" }]' --kind ClusterServiceVersion + cd config/manifests && $(KUSTOMIZE) edit add patch --patch '[{"op":"add", "path":"/spec/replaces", "value": "codeflare-operator.v$(PREVIOUS_VERSION)" }]' --kind ClusterServiceVersion $(KUSTOMIZE) build config/manifests | $(OPERATOR_SDK) generate bundle $(BUNDLE_GEN_FLAGS) $(MAKE) validate-bundle From c5b0a28913ac82c30c5dfb81e733f74e65c3409a Mon Sep 17 00:00:00 2001 From: Kevin Date: Thu, 1 Jun 2023 09:31:56 -0400 Subject: [PATCH 2/2] use unauthenticated red hat registry for Docker file this makes the images easier to build for those outside of the red hat organization Signed-off-by: Kevin --- .github/workflows/operator-image.yml | 7 ------- .github/workflows/tag-and-build.yml | 7 ------- Dockerfile | 2 +- 3 files changed, 1 insertion(+), 15 deletions(-) diff --git a/.github/workflows/operator-image.yml b/.github/workflows/operator-image.yml index 85d0a9ad6..54c6403ab 100644 --- a/.github/workflows/operator-image.yml +++ b/.github/workflows/operator-image.yml @@ -31,13 +31,6 @@ jobs: password: ${{ secrets.QUAY_TOKEN }} registry: quay.io - - name: Login to Red Hat Registry - uses: redhat-actions/podman-login@v1 - with: - username: ${{ secrets.RH_REG_ID }} - password: ${{ secrets.RH_REG_TOKEN }} - registry: registry.redhat.io - - name: Image Build run: | make build diff --git a/.github/workflows/tag-and-build.yml b/.github/workflows/tag-and-build.yml index 38fd559e4..28653862d 100644 --- a/.github/workflows/tag-and-build.yml +++ b/.github/workflows/tag-and-build.yml @@ -46,13 +46,6 @@ jobs: password: ${{ secrets.QUAY_TOKEN }} registry: quay.io - - name: Login to Red Hat Registry - uses: redhat-actions/podman-login@v1 - with: - username: ${{ secrets.RH_REG_ID }} - password: ${{ secrets.RH_REG_TOKEN }} - registry: registry.redhat.io - - name: Image Build run: | make build diff --git a/Dockerfile b/Dockerfile index 8f465f673..b97173679 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # Build the manager binary -FROM registry.redhat.io/ubi8/go-toolset:1.18.9-8 as builder +FROM registry.access.redhat.com/ubi8/go-toolset:1.18.9-8 as builder WORKDIR /workspace # Copy the Go Modules manifests