Skip to content

Commit 689363f

Browse files
committed
Use docker buildx imagetools to create multi-platform manifests
1 parent beee50c commit 689363f

File tree

1 file changed

+63
-56
lines changed

1 file changed

+63
-56
lines changed

.github/workflows/build-and-push.yml

Lines changed: 63 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ env:
1515
FEDORA_VERSION: 42
1616

1717
jobs:
18-
build-and-push:
18+
build-test-and-push:
1919
name: Build, test and push
2020
runs-on: ubuntu-latest
2121
strategy:
@@ -31,51 +31,62 @@ jobs:
3131
toxenv: py39,py310,py312
3232
steps:
3333
- name: Checkout
34-
uses: actions/checkout@v2
34+
uses: actions/checkout@v4
3535
with:
3636
submodules: true
37+
3738
- name: Set up QEMU
38-
uses: docker/setup-qemu-action@v1
39-
- name: Build
40-
uses: docker/build-push-action@v2
39+
uses: docker/setup-qemu-action@v3
40+
41+
- name: Set up Docker Buildx
42+
uses: docker/setup-buildx-action@v3
43+
44+
- name: Build image for testing
45+
uses: docker/build-push-action@v6
4146
with:
4247
context: .
4348
platforms: linux/${{ matrix.arch }}
4449
load: true
4550
tags: |
4651
fedorapython/fedora-python-tox:${{ matrix.arch }}
47-
fedorapython/fedora-python-tox:${{ matrix.arch }}-f${{ env.FEDORA_VERSION }}
52+
4853
- name: Test local project
4954
env:
5055
TOXENV: ${{ matrix.toxenv }}
5156
run: |
5257
docker run --rm --platform linux/${{ matrix.arch }} -v $PWD/example_project:/src -w /src -e TOXENV fedorapython/fedora-python-tox:${{ matrix.arch }}
58+
5359
- name: Test remote project
5460
env:
5561
TOXENV: ${{ matrix.toxenv }}
5662
run: |
5763
docker run --rm --platform linux/${{ matrix.arch }} -e TOXENV -e GIT_URL=https://github.com/frenzymadness/python-tox-example.git fedorapython/fedora-python-tox:${{ matrix.arch }}
64+
5865
- name: Test parallel run
5966
env:
6067
TOXENV: ${{ matrix.toxenv }}
6168
run: |
6269
docker run --rm --platform linux/${{ matrix.arch }} -v $PWD/example_project:/src -w /src -e TOXENV -e TOX_PARAMS="-p auto" fedorapython/fedora-python-tox:${{ matrix.arch }}
70+
6371
- name: Test dnf install and wheel build
6472
env:
6573
TOXENV: ${{ matrix.toxenv }}
6674
run: |
6775
docker run --rm --platform linux/${{ matrix.arch }} -e DNF_INSTALL="libffi-devel 'pkgconfig(libgit2) >= 1.9' /usr/bin/cowsay" fedorapython/fedora-python-tox:${{ matrix.arch }} sh -c "/run_tests.sh; pip install -I --no-deps --compile --no-binary :all: cffi pygit2~=1.17.0 && cowsay DONE"
76+
6877
- name: Test external project with WORKDIR
6978
run: |
7079
docker run --rm --platform linux/${{ matrix.arch }} -e TOXENV=py3 -e GIT_URL=https://github.com/frenzymadness/nflxprofile.git -e WORKDIR=python fedorapython/fedora-python-tox:${{ matrix.arch }}
80+
7181
- name: Login to DockerHub
72-
uses: docker/login-action@v1
82+
uses: docker/login-action@v3
7383
if: github.event_name == 'push' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'
7484
with:
7585
username: ${{ secrets.DOCKERHUB_USERNAME }}
7686
password: ${{ secrets.DOCKERHUB_TOKEN }}
77-
- name: Push to Dockerhub
78-
uses: docker/build-push-action@v2
87+
88+
- name: Build and push platform-specific images
89+
uses: docker/build-push-action@v6
7990
if: github.event_name == 'push' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'
8091
with:
8192
context: .
@@ -85,61 +96,57 @@ jobs:
8596
fedorapython/fedora-python-tox:${{ matrix.arch }}
8697
fedorapython/fedora-python-tox:${{ matrix.arch }}-f${{ env.FEDORA_VERSION }}
8798
88-
description_update:
89-
name: 'Update Dockerhub description'
90-
if: github.event_name == 'push'
91-
needs: build-and-push
99+
release:
100+
name: Create multi-platform manifests
101+
if: github.event_name == 'push' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'
102+
needs: build-test-and-push
92103
runs-on: ubuntu-latest
93104
steps:
94-
- name: Checkout
95-
uses: actions/checkout@v4
96-
- name: 'Update Dockerhub description'
97-
uses: peter-evans/dockerhub-description@v4
105+
- name: Set up Docker Buildx
106+
uses: docker/setup-buildx-action@v3
107+
108+
- name: Login to DockerHub
109+
uses: docker/login-action@v3
98110
with:
99111
username: ${{ secrets.DOCKERHUB_USERNAME }}
100112
password: ${{ secrets.DOCKERHUB_TOKEN }}
101-
repository: fedorapython/fedora-python-tox
102113

103-
release:
104-
name: 'Update and test manifests'
105-
if: github.event_name == 'push' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'
106-
needs: build-and-push
114+
- name: Create and push multi-platform manifest for :latest
115+
run: |
116+
docker buildx imagetools create -t fedorapython/fedora-python-tox:latest \
117+
fedorapython/fedora-python-tox:amd64 \
118+
fedorapython/fedora-python-tox:arm64 \
119+
fedorapython/fedora-python-tox:ppc64le \
120+
fedorapython/fedora-python-tox:s390x
121+
122+
- name: Create and push multi-platform manifest for :f${{ env.FEDORA_VERSION }}
123+
run: |
124+
docker buildx imagetools create -t fedorapython/fedora-python-tox:f${{ env.FEDORA_VERSION }} \
125+
fedorapython/fedora-python-tox:amd64-f${{ env.FEDORA_VERSION }} \
126+
fedorapython/fedora-python-tox:arm64-f${{ env.FEDORA_VERSION }} \
127+
fedorapython/fedora-python-tox:ppc64le-f${{ env.FEDORA_VERSION }} \
128+
fedorapython/fedora-python-tox:s390x-f${{ env.FEDORA_VERSION }}
129+
130+
- name: Verify :latest manifest
131+
run: |
132+
docker buildx imagetools inspect fedorapython/fedora-python-tox:latest
133+
134+
- name: Verify :f${{ env.FEDORA_VERSION }} manifest
135+
run: |
136+
docker buildx imagetools inspect fedorapython/fedora-python-tox:f${{ env.FEDORA_VERSION }}
137+
138+
description_update:
139+
name: Update Dockerhub description
140+
if: github.event_name == 'push'
141+
needs: release
107142
runs-on: ubuntu-latest
108143
steps:
109-
- name: Login to DockerHub
110-
uses: docker/login-action@v1
144+
- name: Checkout
145+
uses: actions/checkout@v4
146+
147+
- name: Update Dockerhub description
148+
uses: peter-evans/dockerhub-description@v4
111149
with:
112150
username: ${{ secrets.DOCKERHUB_USERNAME }}
113151
password: ${{ secrets.DOCKERHUB_TOKEN }}
114-
- name: Pull all images
115-
run: >
116-
for arch in amd64 arm64 ppc64le s390x; do
117-
docker pull fedorapython/fedora-python-tox:$arch;
118-
docker pull fedorapython/fedora-python-tox:${arch}-f${{ env.FEDORA_VERSION }};
119-
done
120-
- name: Create and push manifest for the :latest tag
121-
env:
122-
DOCKER_CLI_EXPERIMENTAL: enabled
123-
run: >
124-
docker manifest create fedorapython/fedora-python-tox:latest
125-
fedorapython/fedora-python-tox:amd64
126-
fedorapython/fedora-python-tox:arm64
127-
fedorapython/fedora-python-tox:ppc64le
128-
fedorapython/fedora-python-tox:s390x;
129-
docker manifest push fedorapython/fedora-python-tox:latest;
130-
- name: Test the latest manifest
131-
run: |
132-
docker manifest inspect fedorapython/fedora-python-tox:latest | grep '"architecture":' | grep -Ez '(.*(amd64|arm64|ppc64le|s390x).*){4}'
133-
- name: Create and push manifest for the versioned tag
134-
env:
135-
DOCKER_CLI_EXPERIMENTAL: enabled
136-
run: >
137-
docker manifest create fedorapython/fedora-python-tox:f${{ env.FEDORA_VERSION }}
138-
fedorapython/fedora-python-tox:amd64-f${{ env.FEDORA_VERSION }}
139-
fedorapython/fedora-python-tox:arm64-f${{ env.FEDORA_VERSION }}
140-
fedorapython/fedora-python-tox:ppc64le-f${{ env.FEDORA_VERSION }}
141-
fedorapython/fedora-python-tox:s390x-f${{ env.FEDORA_VERSION }};
142-
docker manifest push fedorapython/fedora-python-tox:f${{ env.FEDORA_VERSION }};
143-
- name: Test the versioned manifest
144-
run: |
145-
docker manifest inspect fedorapython/fedora-python-tox:f${{ env.FEDORA_VERSION }} | grep '"architecture":' | grep -Ez '(.*(amd64|arm64|ppc64le|s390x).*){4}'
152+
repository: fedorapython/fedora-python-tox

0 commit comments

Comments
 (0)