Skip to content

Upgrade Python base images to Alpine 3.20, drop 3.17 #236

Upgrade Python base images to Alpine 3.20, drop 3.17

Upgrade Python base images to Alpine 3.20, drop 3.17 #236

Workflow file for this run

name: Build base images
on:
pull_request:
branches: ["master"]
release:
types: ["published"]
env:
BUILD_TYPE: base
ALPINE_LATEST: "3.20"
DEBIAN_LATEST: "bookworm"
UBUNTU_LATEST: "20.4"
RASPBIAN_LATEST: "bullseye"
PYTHON_LATEST: "3.12"
jobs:
init:
name: Initialize build
runs-on: ubuntu-latest
outputs:
architectures_alpine: ${{ steps.info_alpine.outputs.architectures }}
architectures_debian: ${{ steps.info_debian.outputs.architectures }}
architectures_ubuntu: ${{ steps.info_ubuntu.outputs.architectures }}
architectures_raspbian: ${{ steps.info_raspbian.outputs.architectures }}
release: ${{ steps.version.outputs.version }}
steps:
- name: Checkout the repository
uses: actions/[email protected]
with:
fetch-depth: 0
- name: Get information Alpine
id: info_alpine
uses: home-assistant/actions/helpers/info@master
with:
path: "${{ github.workspace }}/alpine"
- name: Get information Debian
id: info_debian
uses: home-assistant/actions/helpers/info@master
with:
path: "${{ github.workspace }}/debian"
- name: Get information Ubuntu
id: info_ubuntu
uses: home-assistant/actions/helpers/info@master
with:
path: "${{ github.workspace }}/ubuntu"
- name: Get information Raspbian
id: info_raspbian
uses: home-assistant/actions/helpers/info@master
with:
path: "${{ github.workspace }}/raspbian"
- name: Get version
id: version
uses: home-assistant/actions/helpers/version@master
with:
type: ${{ env.BUILD_TYPE }}
build_alpine:
name: Build ${{ matrix.arch }} alpine ${{ matrix.version }} base image
needs: init
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
packages: write
strategy:
matrix:
arch: ${{ fromJson(needs.init.outputs.architectures_alpine) }}
version: ["3.17", "3.18", "3.19", "3.20"]
steps:
- name: Checkout the repository
uses: actions/[email protected]
- name: Login to GitHub Container Registry
if: github.event_name == 'release'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set build arguments
shell: bash
run: |
if [[ "${{ github.event_name }}" != "release" ]]; then
echo "BUILD_ARGS=--test" >> $GITHUB_ENV
elif [[ "${{ env.ALPINE_LATEST }}" != "${{ matrix.version }}" ]]; then
echo "BUILD_ARGS=--no-latest" >> $GITHUB_ENV
fi
- name: Build base image
uses: home-assistant/[email protected]
with:
args: |
$BUILD_ARGS \
--${{ matrix.arch }} \
--target /data/alpine \
--cosign \
--release ${{ needs.init.outputs.release }} \
--base ${{ matrix.version }}
build_debian:
name: Build ${{ matrix.arch }} debian ${{ matrix.version }} base image
needs: init
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
packages: write
strategy:
matrix:
arch: ${{ fromJson(needs.init.outputs.architectures_debian) }}
version: ["buster", "bullseye", "bookworm"]
steps:
- name: Checkout the repository
uses: actions/[email protected]
- name: Login to GitHub Container Registry
if: github.event_name == 'release'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set build arguments
shell: bash
run: |
if [[ "${{ github.event_name }}" != "release" ]]; then
echo "BUILD_ARGS=--test" >> $GITHUB_ENV
elif [[ "${{ env.DEBIAN_LATEST }}" != "${{ matrix.version }}" ]]; then
echo "BUILD_ARGS=--no-latest" >> $GITHUB_ENV
fi
- name: Build base image
uses: home-assistant/[email protected]
with:
args: |
$BUILD_ARGS \
--${{ matrix.arch }} \
--target /data/debian \
--cosign \
--release ${{ needs.init.outputs.release }} \
--version-from ${{ matrix.version }}-slim \
--base ${{ matrix.version }}
build_ubuntu:
name: Build ${{ matrix.arch }} ubuntu ${{ matrix.version }} base image
needs: init
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
packages: write
strategy:
matrix:
arch: ${{ fromJson(needs.init.outputs.architectures_ubuntu) }}
version: ["16.04", "18.04", "20.04"]
steps:
- name: Checkout the repository
uses: actions/[email protected]
- name: Login to GitHub Container Registry
if: github.event_name == 'release'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set build arguments
shell: bash
run: |
if [[ "${{ github.event_name }}" != "release" ]]; then
echo "BUILD_ARGS=--test" >> $GITHUB_ENV
elif [[ "${{ env.UBUNTU_LATEST }}" != "${{ matrix.version }}" ]]; then
echo "BUILD_ARGS=--no-latest" >> $GITHUB_ENV
fi
- name: Build base image
uses: home-assistant/[email protected]
with:
args: |
$BUILD_ARGS \
--${{ matrix.arch }} \
--target /data/ubuntu \
--cosign \
--release ${{ needs.init.outputs.release }} \
--base ${{ matrix.version }}
build_raspbian:
name: Build ${{ matrix.arch }} raspbian ${{ matrix.version }} base image
needs: init
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
packages: write
strategy:
matrix:
arch: ${{ fromJson(needs.init.outputs.architectures_raspbian) }}
version: ["buster", "bullseye", "bookworm"]
steps:
- name: Checkout the repository
uses: actions/[email protected]
- name: Login to GitHub Container Registry
if: github.event_name == 'release'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set build arguments
shell: bash
run: |
if [[ "${{ github.event_name }}" != "release" ]]; then
echo "BUILD_ARGS=--test" >> $GITHUB_ENV
elif [[ "${{ env.RASPBIAN_LATEST }}" != "${{ matrix.version }}" ]]; then
echo "BUILD_ARGS=--no-latest" >> $GITHUB_ENV
fi
- name: Build base image
uses: home-assistant/[email protected]
with:
args: |
$BUILD_ARGS \
--${{ matrix.arch }} \
--target /data/raspbian \
--cosign \
--release ${{ needs.init.outputs.release }} \
--version-from ${{ matrix.version }}-slim \
--base ${{ matrix.version }}
build_python:
name: Build ${{ matrix.arch }} alpine ${{ matrix.version }} - python ${{ matrix.python }} base image
needs: [init, build_alpine]
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
packages: write
strategy:
matrix:
arch: ${{ fromJson(needs.init.outputs.architectures_alpine) }}
version: ["3.18", "3.19", "3.20"]
python: ["3.10", "3.11", "3.12"]
steps:
- name: Checkout the repository
uses: actions/[email protected]
- name: Login to GitHub Container Registry
if: github.event_name == 'release'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set build arguments
shell: bash
run: |
if [[ "${{ github.event_name }}" != "release" ]]; then
echo "BUILD_ARGS=--test" >> $GITHUB_ENV
elif [[ "${{ env.ALPINE_LATEST }}" != "${{ matrix.version }}" ]] || [[ "${{ env.PYTHON_LATEST }}" != "${{ matrix.python }}" ]]; then
echo "BUILD_ARGS=--no-latest" >> $GITHUB_ENV
fi
- name: Build base image
uses: home-assistant/[email protected]
with:
args: |
$BUILD_ARGS \
--${{ matrix.arch }} \
--target "/data/python/${{ matrix.python }}" \
--cosign \
--release ${{ needs.init.outputs.release }} \
--version-from ${{ matrix.version }} \
--version ${{ matrix.python }} \
--base ${{ matrix.python }}-alpine${{ matrix.version }}