Skip to content

Commit c02be0a

Browse files
committed
Use native arm64 runners instead of QEMU to fix build timeouts
1 parent 3d6afcd commit c02be0a

1 file changed

Lines changed: 49 additions & 18 deletions

File tree

.github/workflows/build-version.yml

Lines changed: 49 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,22 @@ on:
1818

1919
jobs:
2020
build:
21-
runs-on: ubuntu-latest
22-
name: Build Python ${{ inputs.version }}
21+
name: Build Python ${{ inputs.version }} (${{ matrix.platform }})
22+
runs-on: ${{ matrix.runner }}
2323

24-
concurrency:
25-
group: build-python-${{ inputs.version }}
26-
cancel-in-progress: true
24+
strategy:
25+
fail-fast: false
26+
matrix:
27+
include:
28+
- platform: linux/amd64
29+
runner: ubuntu-latest
30+
- platform: linux/arm64
31+
runner: ubuntu-24.04-arm
2732

2833
steps:
2934
- name: Checkout code
3035
uses: actions/checkout@v7
3136

32-
- name: Set up QEMU
33-
uses: docker/setup-qemu-action@v4
34-
3537
- name: Set up Docker Buildx
3638
uses: docker/setup-buildx-action@v4
3739

@@ -42,29 +44,58 @@ jobs:
4244
username: ${{ github.repository_owner }}
4345
password: ${{ secrets.GITHUB_TOKEN }}
4446

45-
- name: Get Git commit short SHA
46-
id: git-sha
47-
run: echo "sha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
47+
- name: Sanitize platform name
48+
id: platform
49+
run: echo "name=$(echo '${{ matrix.platform }}' | tr '/' '-')" >> $GITHUB_OUTPUT
4850

49-
- name: Build and push Docker image
51+
- name: Build and push platform image
5052
uses: docker/build-push-action@v7
5153
with:
5254
context: .
5355
file: ./Dockerfile
5456
target: python-builder
55-
platforms: linux/amd64,linux/arm64
57+
platforms: ${{ matrix.platform }}
5658
push: ${{ github.ref == 'refs/heads/main' }}
5759
cache-to: type=inline
58-
cache-from: type=registry,ref=ghcr.io/python-discord/python-builds:${{ inputs.tag }}
60+
cache-from: |
61+
type=registry,ref=ghcr.io/python-discord/python-builds:builder-base
62+
type=registry,ref=ghcr.io/python-discord/python-builds:${{ inputs.tag }}-${{ steps.platform.outputs.name }}
5963
labels: |
6064
org.opencontainers.image.source=https://github.com/python-discord/python-builds
6165
org.opencontainers.image.description="Python ${{ inputs.version }} Docker image maintained by Python Discord."
6266
org.opencontainers.image.licenses=MIT
63-
outputs: type=image,name=target,annotation-index.org.opencontainers.image.description=Python ${{ inputs.version }} Docker image maintained by Python Discord.
6467
tags: |
65-
ghcr.io/python-discord/python-builds:${{ inputs.tag }}
66-
ghcr.io/python-discord/python-builds:${{ inputs.version }}
67-
ghcr.io/python-discord/python-builds:${{ inputs.tag }}-${{ steps.git-sha.outputs.sha }}
68+
ghcr.io/python-discord/python-builds:${{ inputs.tag }}-${{ steps.platform.outputs.name }}
6869
build-args: |
6970
PYTHON_VERSION=${{ inputs.version }}
7071
PYENV_VERSION=${{ inputs.pyenv_version }}
72+
73+
merge:
74+
name: Merge ${{ inputs.version }} manifests
75+
needs: build
76+
runs-on: ubuntu-latest
77+
if: github.ref == 'refs/heads/main'
78+
79+
steps:
80+
- name: Get Git commit short SHA
81+
id: git-sha
82+
run: echo "sha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
83+
84+
- name: Login to Github Container Registry
85+
uses: docker/login-action@v4
86+
with:
87+
registry: ghcr.io
88+
username: ${{ github.repository_owner }}
89+
password: ${{ secrets.GITHUB_TOKEN }}
90+
91+
- name: Create and push multi-platform manifest
92+
run: |
93+
docker buildx imagetools create \
94+
--annotation "index:org.opencontainers.image.source=https://github.com/python-discord/python-builds" \
95+
--annotation "index:org.opencontainers.image.description=Python ${{ inputs.version }} Docker image maintained by Python Discord." \
96+
--annotation "index:org.opencontainers.image.licenses=MIT" \
97+
--tag ghcr.io/python-discord/python-builds:${{ inputs.tag }} \
98+
--tag ghcr.io/python-discord/python-builds:${{ inputs.version }} \
99+
--tag ghcr.io/python-discord/python-builds:${{ inputs.tag }}-${{ steps.git-sha.outputs.sha }} \
100+
ghcr.io/python-discord/python-builds:${{ inputs.tag }}-linux-amd64 \
101+
ghcr.io/python-discord/python-builds:${{ inputs.tag }}-linux-arm64

0 commit comments

Comments
 (0)