-
Notifications
You must be signed in to change notification settings - Fork 12
255 lines (224 loc) · 9.1 KB
/
release-pipeline.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
name: 🏷️ Release operator and create branches to add new operators versions to repositories for Kubernetes and Openshift
on:
workflow_dispatch:
inputs:
default_bump:
type: choice
description: |
Define what kind of bump you want
options:
- major
- minor
- patch
required: true
operator_version:
type: string
description: |
Define the operator version
required: true
replace_operator_version:
type: string
description: |
Define the operator version to replace
required: true
supported_openshift_range:
type: string
description: |
The supported Openshift version range. This could be a single version, like for example v4.13 or v4.9-v4.13 as a range
required: false
default: v4.13
latest:
required: true
description: |
Define if we want to tag the image as latest too
type: boolean
jobs:
build-and-push:
permissions:
contents: write
env:
VERSION: ${{ github.event.inputs.operator_version }}
USE_IMAGE_DIGESTS: true
runs-on: ubuntu-latest
steps:
- name: "Checkout"
uses: actions/checkout@v4
- name: "Build"
run: make build
- name: "Test"
run: make test
- name: "Set up Go"
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
check-latest: true
- name: "Login to Container registry"
uses: docker/login-action@v3
with:
registry: "quay.io"
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_PASSWORD }}
- name: Set versions
run: |
export INPUT_VERSION="${{ github.event.inputs.operator_version }}"
export C_VERSION="${INPUT_VERSION#v}"
echo "VERSION=${C_VERSION}" >> $GITHUB_ENV
echo "IMG_VERSION=${C_VERSION}" >> $GITHUB_ENV
- name: "Set Up Crane"
run: |
make crane
- name: "Build Container Image"
run: |
export IMAGE_DIGEST=$(bin/crane digest quay.io/kaotoio/kaoto-app:stable)
export KAOTO_APP_IMAGE="quay.io/kaotoio/kaoto-app@${IMAGE_DIGEST}"
make docker-build
make docker-push
- name: "Tag Container Image as latest"
if: ${{ inputs.latest }}
run: |
docker tag quay.io/kaotoio/kaoto-operator:${VERSION} quay.io/kaotoio/kaoto-operator:latest
docker push quay.io/kaotoio/kaoto-operator:latest
- name: "Build OLM bundle"
run: |
make bundle
- name: Checking Diff
run: |
if [[ `git status --porcelain` ]]; then
echo "OK: Changes detected."
echo "OK: Showing changes."
git diff
else
echo "WARNING: No changes were detected."
fi
- name: "🔧 Enrich Bundle"
shell: bash
run: |
cd bundle/manifests
echo " replaces: kaoto-operator.v${{ github.event.inputs.replace_operator_version }}" >> kaoto-operator.clusterserviceversion.yaml
- name: "🔧 Tar bundle"
shell: bash
run: |
tar -czf ${{ runner.temp }}/bundle-${{ github.event.inputs.operator_version }}.tgz -C bundle .
ls -lh ${{ runner.temp }}/bundle-${{ github.event.inputs.operator_version }}.tgz
- name: "🔧 Persist Bundle"
uses: actions/upload-artifact@v4
with:
name: "bundle-${{ github.event.inputs.operator_version }}.tgz"
path: "${{ runner.temp }}/bundle-${{ github.event.inputs.operator_version }}.tgz"
retention-days: 1
tag-and-release:
permissions:
contents: write
runs-on: ubuntu-latest
needs:
- build-and-push
steps:
- uses: actions/checkout@v4
- name: "🛰️ Download Bundle"
uses: actions/download-artifact@v4
with:
name: bundle-${{ github.event.inputs.operator_version }}.tgz
path: "${{ runner.temp }}"
- name: Bump version and push tag
id: tag_version
uses: mathieudutour/github-tag-action@v6.2
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
custom_tag: ${{ github.event.inputs.tag_version }}
create_annotated_tag: true
tag_prefix: "v"
- name: Create a GitHub release
uses: ncipollo/release-action@v1
with:
tag: ${{ steps.tag_version.outputs.new_tag }}
name: Release ${{ steps.tag_version.outputs.new_tag }}
artifacts: "${{ runner.temp }}/bundle-${{ github.event.inputs.operator_version }}.tgz"
prepare-k8s-operator-branch:
permissions:
contents: write
runs-on: ubuntu-latest
needs:
- build-and-push
- tag-and-release
steps:
- name: "Checkout Operarot"
uses: actions/checkout@v4
- name: "Checkout k8s-operator project"
uses: actions/checkout@v4
with:
repository: KaotoIO/community-operators
token: ${{ secrets.KAOTO_CI_TOKEN }}
path: community-operators
ref: main
- name: "🛰️ Download Bundle"
uses: actions/download-artifact@v4
with:
name: bundle-${{ github.event.inputs.operator_version }}.tgz
path: "${{ runner.temp }}"
- name: "Create, prepare branch and open PR for k8s-operator"
env:
BRANCH_NAME: "kaoto-operator.${{ github.event.inputs.operator_version }}"
GH_TOKEN: ${{ secrets.KAOTO_CI_TOKEN }}
run: |
pushd community-operators
echo ""
echo "branch : $BRANCH_NAME"
echo ""
git config user.name github-actions[bot]
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
git remote add upstream https://github.com/k8s-operatorhub/community-operators.git
git pull --rebase upstream main
git push -d origin ${BRANCH_NAME} || echo 'Skip branch deletion'
git checkout -b ${BRANCH_NAME}
mkdir -p operators/kaoto-operator/${{ github.event.inputs.operator_version }}
tar -xzf "${{ runner.temp }}/bundle-${{ github.event.inputs.operator_version }}.tgz" -C operators/kaoto-operator/${{ github.event.inputs.operator_version }}
git add operators/kaoto-operator/${{ github.event.inputs.operator_version }}
git commit -m "operator kaoto-operator (${{ github.event.inputs.operator_version }})"
git push -u origin ${BRANCH_NAME}
gh pr create --title "operator kaoto (${{ github.event.inputs.operator_version }})" -F ../.github/operatorhub/community-operators -R k8s-operatorhub/community-operators
popd
prepare-openshift-operator-branch:
permissions:
contents: write
runs-on: ubuntu-latest
needs:
- build-and-push
- tag-and-release
steps:
- name: "Checkout Operarot"
uses: actions/checkout@v4
- name: "Checkout k8s-operator project"
uses: actions/checkout@v4
with:
repository: KaotoIO/community-operators-prod
token: ${{ secrets.KAOTO_CI_TOKEN }}
path: community-operators-prod
ref: main
- name: "🛰️ Download UI Dist"
uses: actions/download-artifact@v4
with:
name: bundle-${{ github.event.inputs.operator_version }}.tgz
path: "${{ runner.temp }}"
- name: "Create, prepare branch and open PR for community-operators-prod"
env:
BRANCH_NAME: "kaoto-operator.${{ github.event.inputs.operator_version }}"
GH_TOKEN: ${{ secrets.KAOTO_CI_TOKEN }}
run: |
pushd community-operators-prod
echo ""
echo "branch : $BRANCH_NAME"
echo ""
git config user.name github-actions[bot]
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
git remote add upstream https://github.com/redhat-openshift-ecosystem/community-operators-prod.git
git pull --rebase upstream main
git push -d origin ${BRANCH_NAME} || echo 'Skip branch deletion'
git checkout -b ${BRANCH_NAME}
mkdir -p operators/kaoto-operator/${{ github.event.inputs.operator_version }}
tar -xzf "${{ runner.temp }}/bundle-${{ github.event.inputs.operator_version }}.tgz" -C operators/kaoto-operator/${{ github.event.inputs.operator_version }}
echo " com.redhat.openshift.versions: ${{ github.event.inputs.supported_openshift_range }}" >> operators/kaoto-operator/${{ github.event.inputs.operator_version }}/metadata/annotations.yaml
git add operators/kaoto-operator/${{ github.event.inputs.operator_version }}
git commit -m "operator kaoto-operator (${{ github.event.inputs.operator_version }})"
git push -u origin ${BRANCH_NAME}
gh pr create --title "operator kaoto (${{ github.event.inputs.operator_version }})" -F ../.github/openshift/community-operators-prod -R redhat-openshift-ecosystem/community-operators-prod
popd