Skip to content

build(python)

build(python) #57

Workflow file for this run

name: build(python)
on:
workflow_dispatch:
schedule:
- cron: '0 0 3 * *'
jobs:
python:
runs-on: ubuntu-latest
strategy:
matrix:
name: ['python']
suite: ['trixie', 'slim-trixie', 'alpine3.21']
version: ['3.9', '3.10', '3.11', '3.12', '3.13', '3.14-rc']
steps:
- uses: docker/setup-buildx-action@v3
- name: Checkout ${{ matrix.name }}
uses: actions/checkout@v4
- name: Setup QEMU
run: docker run --rm --privileged ghcr.io/loong64/qemu-user-static --reset -p yes
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Get Version
run: |
echo "build=true" >> $GITHUB_ENV
if [ ! -f "${{ matrix.name }}/${{ matrix.version }}/${{ matrix.suite }}/Dockerfile" ]; then
echo "build=false" >> $GITHUB_ENV
exit 0
fi
full_version=$(grep -m1 -oP "ENV PYTHON_VERSION \K.*" ${{ matrix.name }}/${{ matrix.version }}/${{ matrix.suite }}/Dockerfile)
echo "full_version=${full_version}" >> $GITHUB_ENV
version=${{ matrix.version }}
image_tag=${version}
full_image_tag=${full_version}
if echo ${{ matrix.suite }} | grep -q 'alpine'; then
image_tag=${version}-alpine
full_image_tag=${full_version}-alpine
fi
if echo ${{ matrix.suite }} | grep -q 'slim'; then
image_tag=${version}-slim
full_image_tag=${full_version}-slim
fi
echo "image_tag=${image_tag}" >> $GITHUB_ENV
echo "full_image_tag=${full_image_tag}" >> $GITHUB_ENV
- name: Build and push image
if: env.build == 'true'
uses: docker/build-push-action@v6
with:
context: ${{ matrix.name }}/${{ matrix.version }}/${{ matrix.suite }}/
platforms: linux/loong64
push: true
tags: |
ghcr.io/${{ github.repository_owner }}/${{ matrix.name }}:${{ env.image_tag }}
ghcr.io/${{ github.repository_owner }}/${{ matrix.name }}:${{ env.full_image_tag }}
ghcr.io/${{ github.repository_owner }}/${{ matrix.name }}:${{ matrix.version }}-${{ matrix.suite }}
ghcr.io/${{ github.repository_owner }}/${{ matrix.name }}:${{ env.full_version }}-${{ matrix.suite }}
outputs: type=image,oci-mediatypes=true,compression=zstd,compression-level=3,force-compression=true
cache-from: type=gha
cache-to: type=gha,mode=max