@@ -162,6 +162,8 @@ spec:
162
162
value : $(params.git-url)
163
163
- name : revision
164
164
value : $(params.revision)
165
+ - name : fetchTags
166
+ value : true
165
167
runAfter :
166
168
- init
167
169
taskRef :
@@ -183,7 +185,6 @@ spec:
183
185
workspace : workspace
184
186
- name : basic-auth
185
187
workspace : git-auth
186
-
187
188
- name : git-metadata
188
189
runAfter :
189
190
- clone-repository
@@ -202,8 +203,169 @@ spec:
202
203
cd "$(workspaces.source.path)/source"
203
204
echo -n $(date -d @$(git log -1 --format=%at) "+%Y%m%d%H%M") > $(results.commit-timestamp.path)
204
205
results :
205
- - name : commit-timestamp
206
-
206
+ - name : commit-timestamp
207
+ - name : common-get-operator-versions
208
+ runAfter :
209
+ - clone-repository
210
+ workspaces :
211
+ - name : source
212
+ workspace : workspace
213
+ taskSpec :
214
+ workspaces :
215
+ - name : source
216
+ steps :
217
+ - name : get-latest-tag
218
+ image : alpine/git
219
+ script : |
220
+ #!/bin/sh
221
+ set -euo pipefail
222
+ cd "$(workspaces.source.path)/source"
223
+ LATEST_TAG=$(git tag -l --sort=v:refname | tail -n1)
224
+ echo -n $LATEST_TAG > $(results.operator_version_latest.path)
225
+
226
+ echo -n $LATEST_TAG
227
+
228
+ MAJOR=$(echo $LATEST_TAG | cut -d. -f1)
229
+ MINOR=$(echo $LATEST_TAG | cut -d. -f2)
230
+ PATCH=$(echo $LATEST_TAG | cut -d. -f3)
231
+ PATCH=$((PATCH + 1))
232
+ NEW_TAG="$MAJOR.$MINOR.$PATCH"
233
+ echo -n $NEW_TAG > $(results.operator_version_next.path)
234
+ echo -n $NEW_TAG
235
+
236
+ results :
237
+ - name : operator_version_latest
238
+ description : the _latest_ Operator version
239
+ - name : operator_version_next
240
+ description : The _next_ Operator version
241
+ - name : bundle
242
+ runAfter :
243
+ - clone-repository
244
+ - common-get-operator-versions
245
+ workspaces :
246
+ - name : source
247
+ workspace : workspace
248
+ taskSpec :
249
+ params :
250
+ - name : IMAGE
251
+ default : quay.io/ansible/ansible-ai-connect-konflux
252
+ - name : ADDITIONAL_TAGS
253
+ default : " "
254
+ - name : STORAGE_DRIVER
255
+ default : overlay
256
+ workspaces :
257
+ - name : source
258
+ steps :
259
+ - name : bundle
260
+ image : quay.io/operator-framework/operator-sdk:v1.10.0
261
+ script : |
262
+ cd "$(workspaces.source.path)/source"
263
+ operator-sdk generate kustomize manifests -q
264
+
265
+ # install kustomize
266
+ curl -s "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" | bash
267
+ mv kustomize /usr/local/bin/
268
+
269
+ cd config/manager
270
+
271
+ kustomize edit set image controller=$(params.IMAGE):0.1.0
272
+
273
+ cd ../..
274
+ kustomize build config/manifests | operator-sdk generate bundle -q --overwrite --version 0.1.0
275
+ operator-sdk bundle validate ./bundle
276
+ volumeMounts :
277
+ - name : varlibcontainers
278
+ mountPath : /var/lib/containers
279
+ securityContext :
280
+ capabilities :
281
+ add : ["SETFCAP"]
282
+ volumes :
283
+ - name : varlibcontainers
284
+ emptyDir : {}
285
+ - name : update-cluster-service-version
286
+ runAfter :
287
+ - bundle
288
+ workspaces :
289
+ - name : source
290
+ workspace : workspace
291
+ taskSpec :
292
+ workspaces :
293
+ - name : source
294
+ steps :
295
+ - name : update-cluster-service-version
296
+ image : alpine/git
297
+ script : |
298
+ #!/bin/sh
299
+ set -euo pipefail
300
+ cd "$(workspaces.source.path)/source"
301
+ if [[ "$(tasks.common-get-operator-versions.results.operator_version_latest)" == "0.0.0" ]]; then
302
+ >&2 echo "No previous version found."
303
+ exit 0
304
+ fi
305
+
306
+ VERSION="$(tasks.common-get-operator-versions.results.operator_version_next)"
307
+ PREV_VERSION="$(tasks.common-get-operator-versions.results.operator_version_latest)"
308
+ if ! grep -qF "replaces: ansible-ai-connect-operator.v${PREV_VERSION}" bundle/manifests/ansible-ai-connect-operator.clusterserviceversion.yaml; then
309
+ sed -i "/version: ${VERSION}/a\\
310
+ replaces: ansible-ai-connect-operator.v${PREV_VERSION}" ./bundle/manifests/ansible-ai-connect-operator.clusterserviceversion.yaml
311
+ fi
312
+ - name : bundle-build-push
313
+ runAfter :
314
+ - update-cluster-service-version
315
+ workspaces :
316
+ - name : source
317
+ workspace : workspace
318
+ taskSpec :
319
+ params :
320
+ - name : IMAGE
321
+ default : quay.io/ansible/ansible-ai-connect-konflux
322
+ - name : ADDITIONAL_TAGS
323
+ default : " "
324
+ - name : STORAGE_DRIVER
325
+ default : overlay
326
+ workspaces :
327
+ - name : source
328
+ steps :
329
+ - name : bundle-build
330
+ image : quay.io/buildah/stable:v1.17.0
331
+ script : |
332
+ cd "$(workspaces.source.path)/source"
333
+
334
+ OPERATOR_VERSION_NEXT=$(tasks.common-get-operator-versions.results.operator_version_next)
335
+ ADDITIONAL_TAGS="$(params.IMAGE):bundle-$OPERATOR_VERSION_NEXT-pr-{{pull_request_number}}-$(tasks.git-metadata.results.commit-timestamp) $(params.IMAGE):$OPERATOR_VERSION_NEXT"
336
+
337
+ buildah --storage-driver=$(params.STORAGE_DRIVER) bud \
338
+ --no-cache -f bundle.Dockerfile -t $(params.IMAGE) .
339
+
340
+ for tag in $ADDITIONAL_TAGS; do
341
+ buildah tag $(params.IMAGE) $tag
342
+ done
343
+ volumeMounts :
344
+ - name : varlibcontainers
345
+ mountPath : /var/lib/containers
346
+ securityContext :
347
+ capabilities :
348
+ add : ["SETFCAP"]
349
+ - name : bundle-push
350
+ image : quay.io/buildah/stable:v1.17.0
351
+ script : |
352
+ OPERATOR_VERSION_NEXT=$(tasks.common-get-operator-versions.results.operator_version_next)
353
+ ADDITIONAL_TAGS="$(params.IMAGE):bundle-$OPERATOR_VERSION_NEXT-pr-{{pull_request_number}}-$(tasks.git-metadata.results.commit-timestamp) $(params.IMAGE):$OPERATOR_VERSION_NEXT"
354
+
355
+ for tag in $ADDITIONAL_TAGS; do
356
+ buildah --storage-driver=$(params.STORAGE_DRIVER) push \
357
+ $tag
358
+ done
359
+ volumeMounts :
360
+ - name : varlibcontainers
361
+ mountPath : /var/lib/containers
362
+ securityContext :
363
+ capabilities :
364
+ add : ["SETFCAP"]
365
+ volumes :
366
+ - name : varlibcontainers
367
+ emptyDir : {}
368
+
207
369
- name : prefetch-dependencies
208
370
params :
209
371
- name : input
@@ -246,7 +408,7 @@ spec:
246
408
- name : COMMIT_SHA
247
409
value : $(tasks.clone-repository.results.commit)
248
410
- name : BUILD_ARGS
249
- value : ["IMAGE_TAGS=pr-{{pull_request_number}} pr-{{pull_request_number}}. $(tasks.git-metadata.results.commit-timestamp)", "GIT_COMMIT=$(tasks.clone-repository.results.commit )"]
411
+ value : ["IMAGE_TAGS=$(tasks.common-get-operator-versions.results.operator_version_next)- pr-{{pull_request_number}}- $(tasks.git-metadata.results.commit-timestamp)"]
250
412
- name : BUILD_ARGS_FILE
251
413
value : $(params.build-args-file)
252
414
runAfter :
@@ -432,9 +594,10 @@ spec:
432
594
- name : IMAGE
433
595
value : $(tasks.build-container.results.IMAGE_URL)
434
596
- name : ADDITIONAL_TAGS
435
- value : ["pr-{{pull_request_number}}", " pr-{{pull_request_number}}. $(tasks.git-metadata.results.commit-timestamp)"]
597
+ value : ["$(tasks.common-get-operator-versions.results.operator_version_next)- pr-{{pull_request_number}}- $(tasks.git-metadata.results.commit-timestamp)"]
436
598
runAfter :
437
599
- build-container
600
+ - common-get-operator-versions
438
601
taskRef :
439
602
params :
440
603
- name : name
0 commit comments