Skip to content

Commit 746a065

Browse files
authored
Build latest 3 supported k8s version (#78)
Dynamically fetch supported K8s versions for node image builds Use endoflife.date API to build node images for the 3 most recent supported Kubernetes versions instead of a hardcoded list. Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Alice Frosi <afrosi@redhat.com>
1 parent 8cfff71 commit 746a065

1 file changed

Lines changed: 27 additions & 16 deletions

File tree

.github/workflows/build-node-image.yaml

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,25 @@ env:
2121
PUSH_IMAGE: node
2222

2323
jobs:
24+
supported-versions:
25+
runs-on: ubuntu-latest
26+
outputs:
27+
matrix: ${{ steps.set-matrix.outputs.matrix }}
28+
steps:
29+
- name: Get supported Kubernetes versions
30+
id: set-matrix
31+
run: |
32+
MATRIX=$(curl -s https://endoflife.date/api/kubernetes.json | \
33+
jq -c '[.[] | select(.eol > (now | strftime("%Y-%m-%d"))) | .cycle][:3]')
34+
echo "matrix=${MATRIX}" >> "$GITHUB_OUTPUT"
35+
2436
build:
37+
needs: supported-versions
2538
runs-on: ubuntu-latest
39+
strategy:
40+
fail-fast: false
41+
matrix:
42+
kube-minor: ${{ fromJson(needs.supported-versions.outputs.matrix) }}
2643
permissions:
2744
contents: read
2845
packages: write
@@ -42,13 +59,13 @@ jobs:
4259

4360
- name: Build bootc image
4461
working-directory: node-images/fedora
45-
run: make build-bootc-image
62+
run: make build-bootc-image KUBE_MINOR=${{ matrix.kube-minor }}
4663

4764
- name: Determine image tag
4865
id: meta
4966
working-directory: node-images/fedora
5067
run: |
51-
TAG=$(make -s print-image-tag)
68+
TAG=$(make -s print-image-tag KUBE_MINOR=${{ matrix.kube-minor }})
5269
echo "tag=${TAG}" >> "$GITHUB_OUTPUT"
5370
echo "Image tag: ${TAG}"
5471
@@ -58,19 +75,17 @@ jobs:
5875
working-directory: node-images/fedora
5976
run: |
6077
TAG=${{ steps.meta.outputs.tag }}
61-
BOOTC_SRC=$(make -s print-bootc-image)
78+
BOOTC_SRC=$(make -s print-bootc-image KUBE_MINOR=${{ matrix.kube-minor }})
6279
PUSH_DEST=${{ env.PUSH_REGISTRY }}/${{ env.PUSH_IMAGE }}
6380
6481
podman tag ${BOOTC_SRC} ${PUSH_DEST}:${TAG}
6582
podman push --digestfile=/tmp/bootc-digest ${PUSH_DEST}:${TAG}
66-
podman tag ${BOOTC_SRC} ${PUSH_DEST}:latest
67-
podman push ${PUSH_DEST}:latest
6883
6984
BOOTC_DIGEST=$(cat /tmp/bootc-digest)
7085
echo "digest=${BOOTC_DIGEST}" >> "$GITHUB_OUTPUT"
7186
echo "Bootc image pushed with digest: ${BOOTC_DIGEST}"
7287
echo "Clean up local images"
73-
podman rmi -f ${BOOTC_SRC} ${PUSH_DEST}:${TAG} ${PUSH_DEST}:latest
88+
podman rmi -f ${BOOTC_SRC} ${PUSH_DEST}:${TAG}
7489
echo "push_dest=${PUSH_DEST}:${TAG}" >> "$GITHUB_OUTPUT"
7590
7691
- name: Build disk image
@@ -80,44 +95,40 @@ jobs:
8095
PUSH_DEST="${{ steps.push-bootc.outputs.push_dest }}"
8196
if [ -n "${BOOTC_DIGEST}" ] && [ -n "${PUSH_DEST}" ]; then
8297
podman pull "${PUSH_DEST}"
83-
make build-disk-image BOOTC_IMAGE="${PUSH_DEST}" BOOTC_DIGEST="${BOOTC_DIGEST}"
98+
make build-disk-image KUBE_MINOR=${{ matrix.kube-minor }} BOOTC_IMAGE="${PUSH_DEST}" BOOTC_DIGEST="${BOOTC_DIGEST}"
8499
else
85-
make build-disk-image
100+
make build-disk-image KUBE_MINOR=${{ matrix.kube-minor }}
86101
fi
87102
88103
- name: Push disk image
89104
if: github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && inputs.push)
90105
working-directory: node-images/fedora
91106
run: |
92107
TAG=${{ steps.meta.outputs.tag }}
93-
DISK_SRC=$(make -s print-node-image)
108+
DISK_SRC=$(make -s print-node-image KUBE_MINOR=${{ matrix.kube-minor }})
94109
PUSH_DEST=${{ env.PUSH_REGISTRY }}/${{ env.PUSH_IMAGE }}
95110
96111
podman tag ${DISK_SRC} ${PUSH_DEST}:${TAG}-disk
97112
podman push ${PUSH_DEST}:${TAG}-disk
98-
podman tag ${DISK_SRC} ${PUSH_DEST}:latest-disk
99-
podman push ${PUSH_DEST}:latest-disk
100113
101114
- name: Build composefs disk image
102115
working-directory: node-images/fedora
103116
run: |
104117
BOOTC_DIGEST="${{ steps.push-bootc.outputs.digest }}"
105118
PUSH_DEST="${{ steps.push-bootc.outputs.push_dest }}"
106119
if [ -n "${BOOTC_DIGEST}" ] && [ -n "${PUSH_DEST}" ]; then
107-
make build-disk-image-composefs BOOTC_IMAGE="${PUSH_DEST}" BOOTC_DIGEST="${BOOTC_DIGEST}"
120+
make build-disk-image-composefs KUBE_MINOR=${{ matrix.kube-minor }} BOOTC_IMAGE="${PUSH_DEST}" BOOTC_DIGEST="${BOOTC_DIGEST}"
108121
else
109-
make build-disk-image-composefs
122+
make build-disk-image-composefs KUBE_MINOR=${{ matrix.kube-minor }}
110123
fi
111124
112125
- name: Push composefs disk image
113126
if: github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && inputs.push)
114127
working-directory: node-images/fedora
115128
run: |
116129
TAG=${{ steps.meta.outputs.tag }}
117-
DISK_SRC=$(make -s print-node-image-composefs)
130+
DISK_SRC=$(make -s print-node-image-composefs KUBE_MINOR=${{ matrix.kube-minor }})
118131
PUSH_DEST=${{ env.PUSH_REGISTRY }}/${{ env.PUSH_IMAGE }}
119132
120133
podman tag ${DISK_SRC} ${PUSH_DEST}:${TAG}-disk-composefs
121134
podman push ${PUSH_DEST}:${TAG}-disk-composefs
122-
podman tag ${DISK_SRC} ${PUSH_DEST}:latest-disk-composefs
123-
podman push ${PUSH_DEST}:latest-disk-composefs

0 commit comments

Comments
 (0)