-
-
Notifications
You must be signed in to change notification settings - Fork 0
Add arm64 support to CI Docker builds #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
dcd790a
65f1733
253cc7e
98ab7ca
3d6afcd
c02be0a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,68 +17,77 @@ jobs: | |
| 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@v5 | ||
| 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 | ||
| outputs: | ||
| resolved_versions: ${{ steps.resolve_versions.outputs.resolved_versions }} | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v5 | ||
| uses: actions/checkout@v7 | ||
|
|
||
| - name: Set up QEMU | ||
| uses: docker/setup-qemu-action@v4 | ||
|
|
||
| - name: Set up Docker Buildx | ||
| uses: docker/setup-buildx-action@v3 | ||
| uses: docker/setup-buildx-action@v4 | ||
|
|
||
| - name: Login to Github Container Registry | ||
| uses: docker/login-action@v3 | ||
| uses: docker/login-action@v4 | ||
| 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 | ||
| - name: Build and push Python builder base (multi-platform) | ||
| uses: docker/build-push-action@v7 | ||
| with: | ||
| context: . | ||
| file: ./Dockerfile.base | ||
| file: ./Dockerfile | ||
| target: builder-base | ||
| platforms: linux/amd64,linux/arm64 | ||
| 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 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Was there no reason to run this script inside Docker in the first place? |
||
| 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 | ||
| needs: [pyenv-version, build-base] | ||
| strategy: | ||
| matrix: | ||
| version_info: ${{ fromJson(needs.build-base.outputs.resolved_versions) }} | ||
| 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 }} | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,50 +11,91 @@ on: | |
| description: "Version tag to apply to Docker image (e.g. 3.14, 3.14j)" | ||
| required: true | ||
| type: string | ||
| pyenv_version: | ||
| description: "The pyenv version to use when building the builder-base stage" | ||
| required: true | ||
| type: string | ||
|
|
||
| jobs: | ||
| build: | ||
| runs-on: ubuntu-latest | ||
| name: Build Python ${{ inputs.version }} | ||
| name: Build Python ${{ inputs.version }} (${{ matrix.platform }}) | ||
| runs-on: ${{ matrix.runner }} | ||
|
|
||
| concurrency: | ||
| group: build-python-${{ inputs.version }} | ||
| cancel-in-progress: true | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| include: | ||
| - platform: linux/amd64 | ||
| runner: ubuntu-latest | ||
| - platform: linux/arm64 | ||
| runner: ubuntu-24.04-arm | ||
|
|
||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v5 | ||
| uses: actions/checkout@v7 | ||
|
|
||
| - name: Set up Docker Buildx | ||
| uses: docker/setup-buildx-action@v3 | ||
| uses: docker/setup-buildx-action@v4 | ||
|
|
||
| - name: Login to Github Container Registry | ||
| uses: docker/login-action@v3 | ||
| uses: docker/login-action@v4 | ||
| with: | ||
| registry: ghcr.io | ||
| username: ${{ github.repository_owner }} | ||
| password: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| - name: Get Git commit short SHA | ||
| id: git-sha | ||
| run: echo "sha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT | ||
| - name: Sanitize platform name | ||
| id: platform | ||
| run: echo "name=$(echo '${{ matrix.platform }}' | tr '/' '-')" >> $GITHUB_OUTPUT | ||
|
|
||
| - name: Build and push Docker image | ||
| uses: docker/build-push-action@v6 | ||
| - name: Build and push platform image | ||
| uses: docker/build-push-action@v7 | ||
| with: | ||
| context: . | ||
| file: ./Dockerfile | ||
| target: python-builder | ||
| platforms: ${{ matrix.platform }} | ||
| push: ${{ github.ref == 'refs/heads/main' }} | ||
| cache-to: type=inline | ||
| cache-from: type=registry,ref=ghcr.io/python-discord/python-builds:${{ inputs.tag }} | ||
| cache-from: | | ||
| type=registry,ref=ghcr.io/python-discord/python-builds:builder-base | ||
| type=registry,ref=ghcr.io/python-discord/python-builds:${{ inputs.tag }}-${{ steps.platform.outputs.name }} | ||
| labels: | | ||
| org.opencontainers.image.source=https://github.com/python-discord/python-builds | ||
| org.opencontainers.image.description="Python ${{ inputs.version }} Docker image maintained by Python Discord." | ||
| org.opencontainers.image.licenses=MIT | ||
| outputs: type=image,name=target,annotation-index.org.opencontainers.image.description=Python ${{ inputs.version }} Docker image maintained by Python Discord. | ||
| tags: | | ||
| ghcr.io/python-discord/python-builds:${{ inputs.tag }} | ||
| ghcr.io/python-discord/python-builds:${{ inputs.version }} | ||
| ghcr.io/python-discord/python-builds:${{ inputs.tag }}-${{ steps.git-sha.outputs.sha }} | ||
| ghcr.io/python-discord/python-builds:${{ inputs.tag }}-${{ steps.platform.outputs.name }} | ||
| build-args: | | ||
| PYTHON_VERSION=${{ inputs.version }} | ||
| PYENV_VERSION=${{ inputs.pyenv_version }} | ||
|
|
||
| merge: | ||
| name: Merge ${{ inputs.version }} manifests | ||
| needs: build | ||
| runs-on: ubuntu-latest | ||
| if: github.ref == 'refs/heads/main' | ||
|
|
||
| steps: | ||
| - name: Get Git commit short SHA | ||
| id: git-sha | ||
| run: echo "sha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT | ||
|
|
||
| - name: Login to Github Container Registry | ||
| uses: docker/login-action@v4 | ||
| with: | ||
| registry: ghcr.io | ||
| username: ${{ github.repository_owner }} | ||
| password: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| - name: Create and push multi-platform manifest | ||
| run: | | ||
| docker buildx imagetools create \ | ||
| --annotation "index:org.opencontainers.image.source=https://github.com/python-discord/python-builds" \ | ||
| --annotation "index:org.opencontainers.image.description=Python ${{ inputs.version }} Docker image maintained by Python Discord." \ | ||
| --annotation "index:org.opencontainers.image.licenses=MIT" \ | ||
| --tag ghcr.io/python-discord/python-builds:${{ inputs.tag }} \ | ||
| --tag ghcr.io/python-discord/python-builds:${{ inputs.version }} \ | ||
| --tag ghcr.io/python-discord/python-builds:${{ inputs.tag }}-${{ steps.git-sha.outputs.sha }} \ | ||
| ghcr.io/python-discord/python-builds:${{ inputs.tag }}-linux-amd64 \ | ||
| ghcr.io/python-discord/python-builds:${{ inputs.tag }}-linux-arm64 | ||
|
Comment on lines
+100
to
+101
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a way to avoid hard-coding the platforms here? |
||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,7 +16,6 @@ | |
|
|
||
| [config] | ||
| versions = [ | ||
| "3.14", | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why was this removed? |
||
| "3.14t", | ||
| "3.14j", | ||
| "3.13", | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this still needed?