Skip to content

Commit beea46f

Browse files
authored
Merge pull request #3 from jan--f/feat/pr-based-olm-catalog
feat: replace olm-catalog branch with PR-based catalog workflow
2 parents c231661 + e167522 commit beea46f

10 files changed

Lines changed: 723 additions & 218 deletions

File tree

.github/olm-publish/action.yaml

Lines changed: 7 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: 'Publish to OLM'
2-
description: 'Publishes the operator to OLM'
2+
description: 'Publishes the operator to OLM. Expects olm/index-template.yaml to exist in the working tree.'
33
inputs:
44
quay_login:
55
description: "Quay login"
@@ -15,6 +15,7 @@ runs:
1515
shell: bash
1616
run: |
1717
go version
18+
1819
- name: Setup Go environment
1920
uses: actions/setup-go@v5
2021
if: steps.go-version.outcome == 'failure'
@@ -32,34 +33,6 @@ runs:
3233
username: ${{ inputs.quay_login }}
3334
password: ${{ inputs.quay_token }}
3435

35-
- name: Create new integration branch
36-
shell: bash
37-
# Creating a branch here in order to avoid commiting to our local main
38-
# branch further down in this action. In some make targets we use main's sha
39-
# and by creating a branch here we can just assume local main is the same as
40-
# remote main.
41-
run: |
42-
# Discard any uncommitted changes from previous steps (e.g., standard-version)
43-
git reset --hard HEAD
44-
git clean -fd
45-
git checkout -b olm-publish-action-scratch
46-
47-
- name: Fetch olm-catalog branch
48-
shell: bash
49-
run: git fetch origin olm-catalog
50-
51-
- name: Git merge olm-catalog branch
52-
shell: bash
53-
run: |
54-
git config user.name rhobs-release-bot
55-
git config user.email release-bot@monitoring.rhobs.io
56-
57-
# NOTE: uses strategy-option=ours as bundle created for a release using
58-
# make initiate-release conflicts with the previous bundle created for
59-
# development branch, so the version in main takes precedence over the
60-
# one in olm-catalog branch
61-
git merge -Xours origin/olm-catalog -m "ci: merge olm-catalog branch"
62-
6336
- name: Build Operator Image
6437
shell: bash
6538
run: make operator-image
@@ -76,20 +49,12 @@ runs:
7649
shell: bash
7750
run: make bundle-push
7851

79-
8052
- name: Build Catalog Image
8153
shell: bash
82-
run: |
83-
make catalog-image
54+
# update-channels.sh modifies olm/index-template.yaml in place;
55+
# the calling workflow is responsible for committing and opening a PR.
56+
run: make catalog-image
8457

85-
# NOTE: add a commit only if the catalog can built sucessfully
86-
git add bundle/ olm/
87-
git commit -m "ci(bot): update catalog image"
88-
89-
- name: Publish catalog image
58+
- name: Publish Catalog Image
9059
shell: bash
91-
run: |
92-
make catalog-push
93-
94-
# update olm-catalog only if catalog could be successfully published
95-
git push origin HEAD:olm-catalog
60+
run: make catalog-push

.github/workflows/olm-stable.yaml

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,44 @@
11
---
2+
# Triggered when a GitHub pre-release is promoted to a full release.
3+
# Publishes OLM stable images and opens a PR against the corresponding
4+
# release-* branch with the updated catalog index.
25
name: OLM Stable Channel
36

47
on:
58
release:
69
types:
710
- released
811

12+
permissions:
13+
contents: write
14+
pull-requests: write
15+
916
jobs:
1017
release:
1118
runs-on: ubuntu-latest
1219
environment: quay
1320
steps:
21+
- name: Determine release branch
22+
id: branch
23+
run: |
24+
TAG="${{ github.event.release.tag_name }}"
25+
# v1.4.2 -> release-1.4
26+
BRANCH="release-$(echo "${TAG#v}" | cut -d. -f1,2)"
27+
echo "name=$BRANCH" >> "$GITHUB_OUTPUT"
28+
1429
- uses: actions/checkout@v6
1530
with:
31+
ref: ${{ steps.branch.outputs.name }}
1632
fetch-depth: 0
33+
token: ${{ secrets.REPOSITORY_PUSH_TOKEN }}
34+
35+
- name: Setup Go environment
36+
uses: actions/setup-go@v6
37+
with:
38+
go-version-file: 'go.mod'
39+
check-latest: true
1740

18-
- name: publish
41+
- name: Publish catalog
1942
uses: ./.github/olm-publish
2043
env:
2144
IMG_BASE: ${{ vars.IMG_BASE }}
@@ -25,3 +48,27 @@ jobs:
2548
with:
2649
quay_login: ${{ secrets.QUAY_LOGIN }}
2750
quay_token: ${{ secrets.QUAY_TOKEN }}
51+
52+
- name: Open catalog PR
53+
env:
54+
GH_TOKEN: ${{ secrets.REPOSITORY_PUSH_TOKEN }}
55+
run: |
56+
git config user.name rhobs-release-bot
57+
git config user.email release-bot@monitoring.rhobs.io
58+
59+
VERSION="$(cat VERSION)"
60+
TARGET_BRANCH="${{ steps.branch.outputs.name }}"
61+
PR_BRANCH="ci/olm-catalog-stable-${TARGET_BRANCH}"
62+
git checkout -b "$PR_BRANCH"
63+
git add bundle/ olm/index-template.yaml
64+
git commit -m "ci(bot): update OLM stable catalog to ${VERSION}"
65+
git push --force origin "$PR_BRANCH"
66+
67+
existing=$(gh pr list --head "$PR_BRANCH" --base "$TARGET_BRANCH" --json number --jq '.[0].number')
68+
if [ -z "$existing" ]; then
69+
gh pr create \
70+
--base "$TARGET_BRANCH" \
71+
--head "$PR_BRANCH" \
72+
--title "ci: update OLM stable catalog (${VERSION})" \
73+
--body "Automated catalog update for the stable channel."
74+
fi
Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
# Handles RC releases cut from release-* branches.
2+
# Triggered by a chore(release): commit pushed to any release-* branch.
3+
# Creates a GitHub pre-release, publishes OLM candidate images, and opens a PR
4+
# against the release branch with the updated catalog index.
5+
name: Release Branch
6+
on:
7+
push:
8+
branches: ['release-*']
9+
10+
permissions:
11+
contents: write
12+
pull-requests: write
13+
14+
jobs:
15+
e2e-tests-olm:
16+
if: "startsWith(github.event.head_commit.message, 'chore(release):')"
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v6
20+
21+
- name: e2e tests through OLM
22+
uses: ./.github/e2e-tests-olm
23+
24+
create-github-prerelease:
25+
needs:
26+
- e2e-tests-olm
27+
runs-on: ubuntu-latest
28+
steps:
29+
- name: Checkout
30+
uses: actions/checkout@v6
31+
with:
32+
fetch-depth: 0
33+
token: ${{ secrets.REPOSITORY_PUSH_TOKEN }}
34+
persist-credentials: false
35+
36+
# standard-version's release-as relies on controller-gen for code generation.
37+
- name: Setup Go environment
38+
uses: actions/setup-go@v6
39+
with:
40+
go-version-file: 'go.mod'
41+
check-latest: true
42+
43+
- name: Generate release notes
44+
run: |
45+
git config user.name rhobs-release-bot
46+
git config user.email release-bot@monitoring.rhobs.io
47+
npx standard-version -i RELEASE_BODY.md \
48+
--release-as $(cat VERSION) \
49+
--skip.commit
50+
51+
- name: Publish tag
52+
id: publish_tag
53+
run: |
54+
git push --follow-tags
55+
echo "tag_name=$(git describe HEAD --abbrev=0)" >> $GITHUB_OUTPUT
56+
57+
- name: Create Github release
58+
uses: ncipollo/release-action@v1
59+
with:
60+
tag: ${{ steps.publish_tag.outputs.tag_name }}
61+
bodyFile: RELEASE_BODY.md
62+
# NOTE: We always generate pre-releases and mark them as releases manually
63+
prerelease: true
64+
65+
publish-olm-candidate:
66+
needs:
67+
- create-github-prerelease
68+
runs-on: ubuntu-latest
69+
environment: quay
70+
steps:
71+
- name: Checkout
72+
uses: actions/checkout@v6
73+
with:
74+
fetch-depth: 0
75+
token: ${{ secrets.REPOSITORY_PUSH_TOKEN }}
76+
77+
- name: Setup Go environment
78+
uses: actions/setup-go@v6
79+
with:
80+
go-version-file: 'go.mod'
81+
check-latest: true
82+
83+
- name: Set version
84+
id: version
85+
run: |
86+
version="$(cat VERSION)-rc"
87+
echo "version=$version" >> "$GITHUB_OUTPUT"
88+
89+
- name: Publish catalog
90+
uses: ./.github/olm-publish
91+
env:
92+
IMG_BASE: ${{ vars.IMG_BASE }}
93+
VERSION: ${{ steps.version.outputs.version }}
94+
CHANNELS: candidate,development
95+
DEFAULT_CHANNEL: candidate
96+
RELEASE_SHA: ${GITHUB_SHA}
97+
with:
98+
quay_login: ${{ secrets.QUAY_LOGIN }}
99+
quay_token: ${{ secrets.QUAY_TOKEN }}
100+
101+
- name: Open catalog PR
102+
env:
103+
GH_TOKEN: ${{ secrets.REPOSITORY_PUSH_TOKEN }}
104+
run: |
105+
git config user.name rhobs-release-bot
106+
git config user.email release-bot@monitoring.rhobs.io
107+
108+
TARGET_BRANCH="${{ github.ref_name }}"
109+
PR_BRANCH="ci/olm-catalog-candidate-${TARGET_BRANCH}"
110+
git checkout -b "$PR_BRANCH"
111+
git add bundle/ olm/index-template.yaml
112+
git commit -m "ci(bot): update OLM candidate catalog to ${{ steps.version.outputs.version }}"
113+
git push --force origin "$PR_BRANCH"
114+
115+
existing=$(gh pr list --head "$PR_BRANCH" --base "$TARGET_BRANCH" --json number --jq '.[0].number')
116+
if [ -z "$existing" ]; then
117+
gh pr create \
118+
--base "$TARGET_BRANCH" \
119+
--head "$PR_BRANCH" \
120+
--title "ci: update OLM candidate catalog (${{ steps.version.outputs.version }})" \
121+
--body "Automated catalog update for the candidate channel."
122+
fi
123+
124+
- name: Publish Package
125+
uses: ./.github/package-operator-publish
126+
env:
127+
IMG_BASE: ${{ vars.IMG_BASE }}
128+
VERSION: ${{ steps.version.outputs.version }}
129+
with:
130+
quay_login: ${{ secrets.QUAY_LOGIN }}
131+
quay_token: ${{ secrets.QUAY_TOKEN }}
132+
133+
- name: Publish test harness
134+
uses: ./.github/osd-test-harness-publish
135+
env:
136+
IMG_BASE: ${{ vars.IMG_BASE }}
137+
VERSION: ${{ steps.version.outputs.version }}
138+
with:
139+
quay_login: ${{ secrets.QUAY_LOGIN }}
140+
quay_token: ${{ secrets.QUAY_TOKEN }}

0 commit comments

Comments
 (0)