Skip to content

Commit

Permalink
ci: add support to build image for multiple distro versions
Browse files Browse the repository at this point in the history
Signed-off-by: Felix Moessbauer <[email protected]>
  • Loading branch information
fmoessbauer committed Feb 24, 2025
1 parent 2b0025e commit d1e384e
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 5 deletions.
10 changes: 9 additions & 1 deletion .github/actions/docker-init/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ inputs:
required: true
image-name:
required: true
debian-release:
required: false

runs:
using: composite
Expand Down Expand Up @@ -43,11 +45,17 @@ runs:
- name: Determine Debian tag
run: |
COMMIT_DATE=$(date -d @$(git log -1 --pretty=%ct) +%Y%m%d)
DEBIAN_RELEASE=$(grep -m 1 'ARG DEBIAN_TAG=' Dockerfile | sed 's/.*DEBIAN_TAG=\(.*\)-.*/\1/')
DEBIAN_LATEST_RELEASE=$(grep -m 1 'ARG DEBIAN_TAG=' Dockerfile | sed 's/.*DEBIAN_TAG=\(.*\)-.*/\1/')
if [ -n "${{ inputs.debian-release }}" ]; then
DEBIAN_RELEASE="${{ inputs.debian-release }}"
else
DEBIAN_RELEASE=$DEBIAN_LATEST_RELEASE
fi
echo "DEBIAN_TAG=$(podman search --list-tags docker.io/debian --limit 1000000000 | \
grep "$DEBIAN_RELEASE-.*-slim" | sort -r | sed 's/.*[ ]\+//' | \
./scripts/lower-bound.py $DEBIAN_RELEASE-$COMMIT_DATE-slim )" \
>> $GITHUB_ENV
echo "DEBIAN_LATEST_RELEASE=$DEBIAN_LATEST_RELEASE" >> $GITHUB_ENV
shell: bash

- name: Prepare repository for COPY-in
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jobs:
strategy:
matrix:
image-name: ["kas", "kas-isar"]
debian-release: ["bullseye", "bookworm"]
steps:
- name: Check out repo
uses: actions/checkout@v4
Expand Down Expand Up @@ -50,7 +51,9 @@ jobs:
DEBIAN_TAG=${{ env.DEBIAN_TAG }}
provenance: false
outputs: type=registry,rewrite-timestamp=true
tags: ghcr.io/${{ github.repository }}/${{ matrix.image-name }}
tags: |
${{ matrix.debian-release == env.DEBIAN_LATEST_RELEASE && format('{0}/{1}:latest', github.repository, matrix.image-name) || '' }}
ghcr.io/${{ github.repository }}/${{ matrix.image-name }}:latest-${{ matrix.debian-release }}
annotations: ${{ env.DOCKER_METADATA_OUTPUT_ANNOTATIONS }}
- name: Attest ${{ matrix.image-name }} image
uses: actions/attest-build-provenance@v1
Expand Down
10 changes: 7 additions & 3 deletions .github/workflows/next.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ jobs:
strategy:
matrix:
image-name: ["kas", "kas-isar"]
debian-release: ["bullseye", "bookworm"]
steps:
- name: Check out repo
uses: actions/checkout@v4
Expand All @@ -69,6 +70,7 @@ jobs:
deploy-user: ${{ github.actor }}
deploy-token: ${{ secrets.GITHUB_TOKEN }}
image-name: ${{ matrix.image-name }}
debian-release: ${{ matrix.debian-release }}

- name: Build ${{ matrix.image-name }} image
uses: docker/build-push-action@v6
Expand All @@ -80,10 +82,10 @@ jobs:
SOURCE_DATE_EPOCH=${{ env.SOURCE_DATE_EPOCH }}
DEBIAN_TAG=${{ env.DEBIAN_TAG }}
outputs: type=docker,rewrite-timestamp=true
tags: ghcr.io/${{ github.repository }}/${{ matrix.image-name }}:next
tags: ghcr.io/${{ github.repository }}/${{ matrix.image-name }}:next-${{ matrix.debian-release }}
- name: Test ${{ matrix.image-name }} image
env:
KAS_CONTAINER_IMAGE: ghcr.io/${{ github.repository }}/${{ matrix.image-name }}:next
KAS_CONTAINER_IMAGE: ghcr.io/${{ github.repository }}/${{ matrix.image-name }}:next-${{ matrix.debian-release }}
KAS_CLONE_DEPTH: 1
run: |
cd image-tests/${{ matrix.image-name }}
Expand All @@ -110,7 +112,9 @@ jobs:
DEBIAN_TAG=${{ env.DEBIAN_TAG }}
provenance: false
outputs: type=registry,rewrite-timestamp=true
tags: ghcr.io/${{ github.repository }}/${{ matrix.image-name }}:next
tags: |
${{ matrix.debian-release == env.DEBIAN_LATEST_RELEASE && format('{0}/{1}:next', github.repository, matrix.image-name) || '' }}
ghcr.io/${{ github.repository }}/${{ matrix.image-name }}:next-${{ matrix.debian-release }}
annotations: ${{ env.DOCKER_METADATA_OUTPUT_ANNOTATIONS }}
- name: Attest ${{ matrix.image-name }} image
if: github.ref == 'refs/heads/next'
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jobs:
strategy:
matrix:
image-name: ["kas", "kas-isar"]
debian-release: ["bullseye", "bookworm"]
steps:
- name: Check out repo
uses: actions/checkout@v4
Expand Down

0 comments on commit d1e384e

Please sign in to comment.