Skip to content

Commit f228dba

Browse files
KPostOfficeopenshift-merge-robot
authored andcommitted
add new github action which tags and builds a new operator
Signed-off-by: Kevin <[email protected]>
1 parent 1616ded commit f228dba

File tree

2 files changed

+76
-1
lines changed

2 files changed

+76
-1
lines changed

Diff for: .github/workflows/tag-and-build.yml

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# This workflow will build the CodeFlare Operator image and push it to the project-codeflare image registry
2+
3+
name: Tag and Release
4+
on:
5+
workflow_dispatch:
6+
inputs:
7+
version:
8+
description: 'Tag to be used for operator image'
9+
required: true
10+
default: '0.0.0-dev'
11+
replaces:
12+
description: 'The previous semantic version that this tag replaces.'
13+
required: true
14+
default: '0.0.0-dev'
15+
16+
jobs:
17+
push:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions/checkout@v3
21+
22+
- name: Activate cache
23+
uses: actions/cache@v2
24+
with:
25+
path: /cache
26+
key: ${{ runner.os }}-cache-${{ hashFiles('**/go.sum', '.pre-commit-config.yaml') }}
27+
28+
- name: Create tag
29+
uses: actions/github-script@v6
30+
with:
31+
script: |
32+
github.rest.git.createRef({
33+
owner: context.repo.owner,
34+
repo: context.repo.repo,
35+
ref: 'refs/tags/${{ github.event.inputs.version }}',
36+
sha: context.sha
37+
})
38+
39+
- name: Install operator-sdk
40+
run: make install-operator-sdk
41+
42+
- name: Login to Quay.io
43+
uses: redhat-actions/podman-login@v1
44+
with:
45+
username: ${{ secrets.QUAY_ID }}
46+
password: ${{ secrets.QUAY_TOKEN }}
47+
registry: quay.io
48+
49+
- name: Login to Red Hat Registry
50+
uses: redhat-actions/podman-login@v1
51+
with:
52+
username: ${{ secrets.RH_REG_ID }}
53+
password: ${{ secrets.RH_REG_TOKEN }}
54+
registry: registry.redhat.io
55+
56+
- name: Image Build
57+
run: |
58+
make build
59+
make bundle
60+
make image-build -e IMG=quay.io/project-codeflare/codeflare-operator:${SOURCE_TAG}
61+
podman tag quay.io/project-codeflare/codeflare-operator:${SOURCE_TAG} quay.io/project-codeflare/codeflare-operator:latest
62+
env:
63+
SOURCE_TAG: ${{ github.event.inputs.version }}
64+
65+
- name: Image Push
66+
run: |
67+
make image-push -e IMG=quay.io/project-codeflare/codeflare-operator:${SOURCE_TAG}
68+
make image-push -e IMG=quay.io/project-codeflare/codeflare-operator:latest
69+
env:
70+
SOURCE_TAG: ${{ github.event.inputs.version }}

Diff for: Makefile

+6-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@
33
# To re-generate a bundle for another specific version without changing the standard setup, you can:
44
# - use the VERSION as arg of the bundle target (e.g make bundle VERSION=0.0.2)
55
# - use environment variables to overwrite this value (e.g export VERSION=0.0.2)
6-
VERSION ?= 0.0.2
6+
# best if we could detect this. If we cannot, we need to document it somewhere.
7+
# then we can add a patch in the `PHONY: bundle`
8+
9+
PREVIOUS_VERSION ?= 0.0.3
10+
VERSION ?= 0.0.3-dev
711

812
# CHANNELS define the bundle channels used in the bundle.
913
# 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
193197
$(OPERATOR_SDK) generate kustomize manifests -q
194198
cd config/manager && $(KUSTOMIZE) edit set image controller=$(IMG)
195199
cd config/manifests && $(KUSTOMIZE) edit add patch --patch '[{"op":"add", "path":"/metadata/annotations/containerImage", "value": "$(IMG)" }]' --kind ClusterServiceVersion
200+
cd config/manifests && $(KUSTOMIZE) edit add patch --patch '[{"op":"add", "path":"/spec/replaces", "value": "codeflare-operator.v$(PREVIOUS_VERSION)" }]' --kind ClusterServiceVersion
196201
$(KUSTOMIZE) build config/manifests | $(OPERATOR_SDK) generate bundle $(BUNDLE_GEN_FLAGS)
197202
$(MAKE) validate-bundle
198203

0 commit comments

Comments
 (0)