|
| 1 | +name: Release of NCCL Tests container multi-arch |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + paths: |
| 6 | + - 'hpc/applications/sphexa/Containerfile' |
| 7 | + - '.github/workflows/release-sphexa.yml' |
| 8 | + workflow_dispatch: |
| 9 | + |
| 10 | +permissions: |
| 11 | + contents: write |
| 12 | + packages: write |
| 13 | + actions: read |
| 14 | + |
| 15 | +env: |
| 16 | + REGISTRY: ghcr.io |
| 17 | + REPO: ghcr.io/${{ github.repository }}/sphexa |
| 18 | + |
| 19 | +jobs: |
| 20 | + build: |
| 21 | + strategy: |
| 22 | + matrix: |
| 23 | + include: |
| 24 | + - arch: amd64 |
| 25 | + runner: ubuntu-latest |
| 26 | + - arch: arm64 |
| 27 | + runner: ubuntu-24.04-arm |
| 28 | + runs-on: ${{ matrix.runner }} |
| 29 | + |
| 30 | + steps: |
| 31 | + - name: Checkout code |
| 32 | + uses: actions/checkout@v4 |
| 33 | + |
| 34 | + - name: Set up Docker Buildx |
| 35 | + uses: docker/setup-buildx-action@v3 |
| 36 | + id: buildx |
| 37 | + |
| 38 | + - name: Log in to GHCR |
| 39 | + uses: docker/login-action@v1 |
| 40 | + with: |
| 41 | + registry: ${{ env.REGISTRY }} |
| 42 | + username: ${{ github.actor }} |
| 43 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 44 | + |
| 45 | + - name: Build & push single-arch image |
| 46 | + run: | |
| 47 | + docker buildx build \ |
| 48 | + --builder "${{ steps.buildx.outputs.name }}" \ |
| 49 | + --platform linux/${{ matrix.arch }} \ |
| 50 | + --file hpc/applications/sphexa/Containerfile \ |
| 51 | + --tag "${{ env.REPO }}:build-${{ matrix.arch }}" \ |
| 52 | + --push \ |
| 53 | + . |
| 54 | +
|
| 55 | +# Multi-arch manifest that references both images |
| 56 | + manifest: |
| 57 | + name: Create multi-arch manifest |
| 58 | + needs: build |
| 59 | + runs-on: ubuntu-latest |
| 60 | + |
| 61 | + steps: |
| 62 | + - name: Log in to GHCR |
| 63 | + uses: docker/login-action@v1 |
| 64 | + with: |
| 65 | + registry: ${{ env.REGISTRY }} |
| 66 | + username: ${{ github.actor }} |
| 67 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 68 | + |
| 69 | + - name: Verify single-arch images exist |
| 70 | + run: | |
| 71 | + set -euo pipefail |
| 72 | +
|
| 73 | + IMAGES=( |
| 74 | + "${{ env.REPO }}:build-amd64" |
| 75 | + "${{ env.REPO }}:build-arm64" |
| 76 | + ) |
| 77 | +
|
| 78 | + for img in "${IMAGES[@]}"; do |
| 79 | + echo "Inspecting $img ..." |
| 80 | + if ! docker buildx imagetools inspect "$img" > /dev/null; then |
| 81 | + echo "::error file=manifest.yml::Image not found: $img" |
| 82 | + exit 1 |
| 83 | + fi |
| 84 | + done |
| 85 | +
|
| 86 | + - name: Create & push multi-arch manifest |
| 87 | + run: | |
| 88 | + TAG=$(skopeo inspect --config docker://${{ env.REPO }}:build-amd64 | jq '.config.Labels["org.opencontainers.image.version"]' | tr -d '"') |
| 89 | + docker buildx imagetools create \ |
| 90 | + --tag "${{ env.REPO }}:${TAG}" \ |
| 91 | + "${{ env.REPO }}:build-amd64" \ |
| 92 | + "${{ env.REPO }}:build-arm64" |
| 93 | +
|
| 94 | + - name: Log in to GHCR with Podman |
| 95 | + uses: redhat-actions/podman-login@v1 |
| 96 | + with: |
| 97 | + registry: ${{ env.REGISTRY }} |
| 98 | + username: ${{ github.actor }} |
| 99 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 100 | + |
| 101 | + - name: Cleanup temporary single-arch images |
| 102 | + run: | |
| 103 | + skopeo delete docker://"${{ env.REPO }}:build-amd64" |
| 104 | + skopeo delete docker://"${{ env.REPO }}:build-arm64" |
0 commit comments