Skip to content

Commit c3e9b2a

Browse files
authored
Fix action release version (#9)
* fix release version from confluent kafka python Signed-off-by: Francisco Vila <[email protected]> * test get latest quay version Signed-off-by: Francisco Vila <[email protected]> * test get latest quay version Signed-off-by: Francisco Vila <[email protected]> * remove unused steps Signed-off-by: Francisco Vila <[email protected]> --------- Signed-off-by: Francisco Vila <[email protected]> Signed-off-by: Francisco Vila <[email protected]>
1 parent 4b1b720 commit c3e9b2a

File tree

2 files changed

+93
-24
lines changed

2 files changed

+93
-24
lines changed

.github/workflows/cron.yml

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one or more
3+
# contributor license agreements. See the NOTICE file distributed with
4+
# this work for additional information regarding copyright ownership.
5+
# The ASF licenses this file to You under the Apache License, Version 2.0
6+
# (the "License"); you may not use this file except in compliance with
7+
# the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
# pythonkafkaclient.yaml - builds and pushes a Python Kafka Client container image.
18+
#
19+
# Requires repository variables:
20+
# - REGISTRY_SERVER - the server of the container registry service e.g. `quay.io` or `docker.io`
21+
# - REGISTRY_USERNAME - - your username on the service (or username of your robot account)
22+
# - REGISTRY_TOKEN - the access token that corresponds to `REGISTRY_USERNAME`
23+
#
24+
25+
name: Cron Scheduled Python Kafka Client Container
26+
on:
27+
schedule:
28+
- cron: '0 0 * * 5'
29+
workflow_dispatch:
30+
jobs:
31+
build:
32+
runs-on: ubuntu-latest
33+
if: ${{ vars.REGISTRY_SERVER != '' && vars.REGISTRY_USERNAME != '' }}
34+
steps:
35+
- name: 'Get latest release version of confluent kafka python package'
36+
id: confluentKafkaPython
37+
uses: pozetroninc/[email protected]
38+
with:
39+
repository: confluentinc/confluent-kafka-python
40+
excludes: prerelease, draft
41+
- name: 'Get latest release version of this repository'
42+
id: pythonKafkaClientRelease
43+
uses: pozetroninc/[email protected]
44+
with:
45+
repository: kroxylicious/python-kafka-test-client
46+
- name: 'Determine Version'
47+
id: confluentKafkaPythonVersion
48+
run: |
49+
REPO_RELEASE=${{ steps.confluentKafkaPython.outputs.release }}
50+
RELEASE=$(echo ${REPO_RELEASE//v})
51+
echo "$RELEASE"
52+
echo "LIBRDKAFKA_VERSION=${RELEASE}" >> $GITHUB_ENV
53+
- name: 'Set release version from new tag'
54+
if: ${{ contains(github.ref, 'tag') }}
55+
run: |
56+
REPO_RELEASE=${{ github.ref_name }}
57+
echo "RELEASE_VERSION=${REPO_RELEASE}" >> $GITHUB_ENV
58+
- name: 'Set release version from latest tag'
59+
if: ${{ ! contains(github.ref, 'tag') }}
60+
run: |
61+
REPO_RELEASE=${{ steps.pythonKafkaClientRelease.outputs.release }}
62+
echo "RELEASE_VERSION=${REPO_RELEASE}" >> $GITHUB_ENV
63+
- name: 'Check out repository from latest tag'
64+
uses: actions/checkout@v6
65+
with:
66+
ref: ${{ env.RELEASE_VERSION }}
67+
fetch-depth: 0
68+
- name: 'Set up QEMU'
69+
uses: docker/setup-qemu-action@v3
70+
- name: Set up Docker Buildx
71+
id: buildx
72+
uses: docker/setup-buildx-action@v3
73+
- name: 'Login to container registry'
74+
uses: docker/login-action@v3
75+
with:
76+
registry: ${{ vars.REGISTRY_SERVER }}
77+
username: ${{ vars.REGISTRY_USERNAME }}
78+
password: ${{ secrets.REGISTRY_TOKEN }}
79+
- name: 'Build and push python kafka client container image'
80+
uses: docker/build-push-action@v6
81+
with:
82+
context: .
83+
build-args: LIBRDKAFKA_VERSION=${{env.LIBRDKAFKA_VERSION}}
84+
platforms: linux/amd64,linux/arm64,linux/s390x,linux/ppc64le
85+
push: true
86+
tags: ${{ vars.REGISTRY_DESTINATION }}:${{ env.RELEASE_VERSION }}-${{ env.LIBRDKAFKA_VERSION }}
87+
cache-from: type=gha
88+
cache-to: type=gha,mode=max,compression=zstd

.github/workflows/pythonkafkaclient.yml

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@
2424

2525
name: Python Kafka Client Container
2626
on:
27-
schedule:
28-
- cron: '0 0 * * 5'
2927
push:
3028
tags: [ '*.*.*' ]
3129
workflow_dispatch:
@@ -34,34 +32,17 @@ jobs:
3432
runs-on: ubuntu-latest
3533
if: ${{ vars.REGISTRY_SERVER != '' && vars.REGISTRY_USERNAME != '' }}
3634
steps:
37-
- name: 'Get latest release version of confluent kafka python package'
38-
id: confluentKafkaPython
39-
uses: pozetroninc/[email protected]
40-
with:
41-
repository: confluentinc/confluent-kafka-python
42-
excludes: prerelease, draft
43-
- name: 'Get latest release version of this repository'
44-
id: pythonKafkaClientRelease
45-
uses: pozetroninc/[email protected]
46-
with:
47-
repository: kroxylicious/python-kafka-test-client
48-
- name: 'Determine Version'
49-
id: confluentKafkaPythonVersion
35+
- name: 'Get latest librdkafka version used'
5036
run: |
51-
REPO_RELEASE=${{ steps.confluentKafkaPython.outputs.release }}
52-
RELEASE=$(echo ${REPO_RELEASE//v})
53-
echo "$RELEASE"
54-
echo "LIBRDKAFKA_VERSION=${RELEASE}" >> $GITHUB_ENV
37+
TAG=$(curl -H "Authorization: Bearer XYZ" -X GET "https://${{vars.REGISTRY_SERVER}}/api/v1/repository/${{REGISTRY_ORGANISATION}}/python-kafka-test-client/tag/" | jq .tags[].name | head -1 | sed -e 's|\"||g')
38+
arrTag=(${TAG//-/ })
39+
echo "${arrTag[1]}"
40+
echo "LIBRDKAFKA_VERSION=${arrTag[1]}" >> $GITHUB_ENV
5541
- name: 'Set release version from new tag'
5642
if: ${{ contains(github.ref, 'tag') }}
5743
run: |
5844
REPO_RELEASE=${{ github.ref_name }}
5945
echo "RELEASE_VERSION=${REPO_RELEASE}" >> $GITHUB_ENV
60-
- name: 'Set release version from latest tag'
61-
if: ${{ ! contains(github.ref, 'tag') }}
62-
run: |
63-
REPO_RELEASE=${{ steps.pythonKafkaClientRelease.outputs.release }}
64-
echo "RELEASE_VERSION=${REPO_RELEASE}" >> $GITHUB_ENV
6546
- name: 'Check out repository from latest tag'
6647
uses: actions/checkout@v6
6748
with:

0 commit comments

Comments
 (0)