Build Python Interpreters #36
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v5 | |
| with: | |
| repository: pyenv/pyenv | |
| fetch-depth: 0 | |
| fetch-tags: true | |
| - name: Get latest pyenv version | |
| id: get_pyenv_version | |
| run: | | |
| echo "pyenv_version=$(git describe --abbrev=0 --tags)" >> $GITHUB_OUTPUT | |
| build-base: | |
| name: Build Python Builder Base | |
| needs: pyenv-version | |
| outputs: | |
| resolved_versions: ${{ steps.resolve_versions.outputs.resolved_versions }} | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v5 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to Github Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.repository_owner }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build and push Python builder base | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| file: ./Dockerfile.base | |
| push: ${{ github.ref == 'refs/heads/main' }} | |
| cache-to: type=inline | |
| load: true | |
| 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 }} | |
| - name: Run Docker container to resolve versions | |
| id: resolve_versions | |
| run: | | |
| resolved_versions=$(docker run --mount type=bind,src=./versions.toml,dst=/versions.toml --rm ghcr.io/python-discord/python-builds:builder-base python3 /scripts/find_version.py) | |
| # JSON array with objects containing "tag" and "version" keys | |
| echo "resolved_versions=$resolved_versions" >> $GITHUB_OUTPUT | |
| build-versions: | |
| name: Build Python Versions | |
| needs: build-base | |
| strategy: | |
| matrix: | |
| version_info: ${{ fromJson(needs.build-base.outputs.resolved_versions) }} | |
| uses: ./.github/workflows/build-version.yml | |
| with: | |
| version: ${{ matrix.version_info.version }} | |
| tag: ${{ matrix.version_info.tag }} |