|
name: Build Python Interpreters |
|
|
|
on: |
|
push: |
|
branches: |
|
- main |
|
schedule: |
|
- cron: '0 */12 * * *' # Every 12 hours |
|
workflow_dispatch: |
|
pull_request: |
|
branches: |
|
- main |
|
|
|
jobs: |
|
pyenv-version: |
|
name: Find latest pyenv version |
|
runs-on: ubuntu-latest |
|
outputs: |
|
pyenv_version: ${{ steps.get_pyenv_version.outputs.pyenv_version }} |
|
resolved_versions: ${{ steps.resolve_versions.outputs.resolved_versions }} |
|
steps: |
|
- name: Checkout code |
|
uses: actions/checkout@v7 |
|
|
|
- name: Checkout pyenv |
|
uses: actions/checkout@v7 |
|
with: |
|
repository: pyenv/pyenv |
|
fetch-depth: 0 |
|
fetch-tags: true |
|
path: pyenv |
|
|
|
- name: Get latest pyenv version |
|
id: get_pyenv_version |
|
run: | |
|
cd pyenv |
|
echo "pyenv_version=$(git describe --abbrev=0 --tags)" >> $GITHUB_OUTPUT |
|
|
|
- name: Resolve Python versions |
|
id: resolve_versions |
|
run: | |
|
resolved_versions=$(PYENV_ROOT=./pyenv VERSIONS_TOML=./versions.toml python3 scripts/find_version.py) |
|
# JSON array with objects containing "tag" and "version" keys |
|
echo "resolved_versions=$resolved_versions" >> $GITHUB_OUTPUT |
|
|
|
build-base: |
|
name: Build Python Builder Base |
|
needs: pyenv-version |
|
runs-on: ubuntu-latest |
|
steps: |
|
- name: Checkout code |
|
uses: actions/checkout@v7 |
|
|
|
- name: Set up QEMU |
|
uses: docker/setup-qemu-action@v4 |
|
|
|
- name: Set up Docker Buildx |
|
uses: docker/setup-buildx-action@v4 |
|
|
|
- name: Login to Github Container Registry |
|
uses: docker/login-action@v4 |
|
with: |
|
registry: ghcr.io |
|
username: ${{ github.repository_owner }} |
|
password: ${{ secrets.GITHUB_TOKEN }} |
|
|
|
- name: Build and push Python builder base (multi-platform) |
|
uses: docker/build-push-action@v7 |
|
with: |
|
context: . |
|
file: ./Dockerfile |
|
target: builder-base |
|
platforms: linux/amd64,linux/arm64 |
|
push: ${{ github.ref == 'refs/heads/main' }} |
|
cache-to: type=inline |
|
cache-from: type=registry,ref=ghcr.io/python-discord/python-builds:builder-base |
|
build-args: | |
|
PYENV_VERSION=${{ needs.pyenv-version.outputs.pyenv_version }} |
|
tags: | |
|
ghcr.io/python-discord/python-builds:builder-base |
|
ghcr.io/python-discord/python-builds:builder-base-${{ needs.pyenv-version.outputs.pyenv_version }} |
|
|
|
build-versions: |
|
name: Build Python Versions |
|
needs: [pyenv-version, build-base] |
|
strategy: |
|
matrix: |
|
version_info: ${{ fromJson(needs.pyenv-version.outputs.resolved_versions) }} |
|
uses: ./.github/workflows/build-version.yml |
|
with: |
|
version: ${{ matrix.version_info.version }} |
|
tag: ${{ matrix.version_info.tag }} |
|
pyenv_version: ${{ needs.pyenv-version.outputs.pyenv_version }} |