Skip to content
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

feat: deploy multi-arch images #1755

Merged
merged 1 commit into from
Mar 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .github/workflows/multiarch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Deploy multi-arch images

on:
workflow_dispatch:
schedule:
- cron: "30 5 * * *" # every day, at 5:30

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: false

jobs:
deploy:
name: Deploy multi-arch images
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install ORAS
run: sudo snap install oras --classic
- name: Deploy
if: github.repository == 'pypa/manylinux'
run: ./deploy_multiarch.sh
env:
QUAY_USERNAME: ${{ secrets.QUAY_USERNAME }}
QUAY_PASSWORD: ${{ secrets.QUAY_PASSWORD }}
65 changes: 65 additions & 0 deletions deploy_multiarch.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#!/bin/bash

set -euo pipefail

IMAGES=(manylinux2014 manylinux_2_28 manylinux_2_31 manylinux_2_34 musllinux_1_2)

podman login -u "${QUAY_USERNAME}" -p "${QUAY_PASSWORD}" quay.io

for IMAGE in "${IMAGES[@]}"; do
echo "::group::${IMAGE}"
LAST_TAG="$(oras repo tags --last "2025.02.23-1" "quay.io/pypa/${IMAGE}" | tail -2 | head -1)"
if [ "${LAST_TAG}" == "" ]; then
LAST_TAG=2025.02.23-1
fi
echo "${IMAGE}: last tag is ${LAST_TAG}"
case ${IMAGE} in
manylinux_2_31) REF_IMAGE=manylinux_2_31_armv7l;;
*) REF_IMAGE=${IMAGE}_x86_64;;
esac
TAGS_TO_PUSH=()
while IFS='' read -r LINE; do
TAGS_TO_PUSH+=("$LINE");
done < <(oras repo tags --last "${LAST_TAG}" "quay.io/pypa/${REF_IMAGE}" | grep -v "^20[0-9][0-9]-" | grep -v "latest")
if [ ${#TAGS_TO_PUSH[@]} -eq 0 ]; then
echo "${IMAGE}: up-to-date"
echo "::endgroup::"
continue
fi

echo "${IMAGE}: adding tags ${TAGS_TO_PUSH[*]}"
case ${IMAGE} in
manylinux_2_31) ARCHS=("armv7l");;
manylinux2014) ARCHS=("x86_64" "i686" "aarch64" "ppc64le" "s390x");;
musllinux_1_2) ARCHS=("x86_64" "i686" "aarch64" "armv7l" "ppc64le" "s390x");;
*) ARCHS=("x86_64" "aarch64" "ppc64le" "s390x");;
esac

LATEST_MANIFEST=
for TAG_TO_PUSH in "${TAGS_TO_PUSH[@]}"; do
echo "::group::${TAG_TO_PUSH}"
SRC_IMAGES=()
for ARCH in "${ARCHS[@]}"; do
SRC_IMAGES+=("docker://quay.io/pypa/${IMAGE}_${ARCH}:${TAG_TO_PUSH}")
done
MANIFEST="${IMAGE}:${TAG_TO_PUSH}"
if ! podman manifest create "${MANIFEST}" "${SRC_IMAGES[@]}"; then
echo "::error ::failed to create '${MANIFEST}' manifest using ${SRC_IMAGES[*]}"
else
if ! podman manifest push --all "${MANIFEST}" "docker://quay.io/pypa/${IMAGE}:${TAG_TO_PUSH}"; then
echo "::error ::failed to push 'quay.io/pypa/${IMAGE}:${TAG_TO_PUSH}' using '${MANIFEST}'"
else
LATEST_MANIFEST="${MANIFEST}"
fi
fi
echo "::endgroup::"
done
if [ "${LATEST_MANIFEST}" == "" ]; then
echo "::warning ::${IMAGE}: skipping latest due to previous errors"
else
if ! podman manifest push --all "${LATEST_MANIFEST}" "docker://quay.io/pypa/${IMAGE}:latest"; then
echo "::error ::failed to push 'quay.io/pypa/${IMAGE}:latest' using '${LATEST_MANIFEST}'"
fi
fi
echo "::endgroup::"
done
Loading