@@ -250,8 +250,8 @@ jobs:
250250 ${{github.event_name != 'pull_request' && github.ref == 'refs/heads/main'}}
251251 token : " ${{secrets.GITHUB_TOKEN}}"
252252
253- ubuntu-jammy-deps-image :
254- name : " ubuntu-jammy-deps-image"
253+ ubuntu-jammy-x86_64- deps-image :
254+ name : " ubuntu-jammy-x86_64- deps-image"
255255 if : " needs.filter-relevant-changes.outputs.ubuntu_jammy_image_changed == 'true'"
256256 needs : " filter-relevant-changes"
257257 runs-on : *runner
@@ -276,6 +276,35 @@ jobs:
276276 ${{github.event_name != 'pull_request' && github.ref == 'refs/heads/main'}}
277277 token : " ${{secrets.GITHUB_TOKEN}}"
278278
279+ ubuntu-jammy-aarch64-deps-image :
280+ name : " ubuntu-jammy-aarch64-deps-image"
281+ if : >-
282+ needs.filter-relevant-changes.outputs.ubuntu_jammy_image_changed == 'true'
283+ && github.event_name != 'pull_request'
284+ && github.ref == 'refs/heads/main'
285+ needs : " filter-relevant-changes"
286+ runs-on : " ubuntu-24.04-arm"
287+ steps :
288+ - uses : " actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd" # v6.0.2
289+ with :
290+ submodules : " recursive"
291+
292+ - name : " Work around actions/runner-images/issues/6775"
293+ run : " chown $(id -u):$(id -g) -R ."
294+ shell : " bash"
295+
296+ - uses : " ./.github/actions/clp-core-build-containers"
297+ env :
298+ OS_NAME : " ubuntu-jammy"
299+ with :
300+ image_name : " ${{env.DEPS_IMAGE_NAME_PREFIX_AARCH64}}${{env.OS_NAME}}"
301+ docker_context : " components/core"
302+ docker_file : " components/core/tools/docker-images/clp-env-base-${{env.OS_NAME}}\
303+ /Dockerfile"
304+ push_deps_image : >-
305+ ${{github.event_name != 'pull_request' && github.ref == 'refs/heads/main'}}
306+ token : " ${{secrets.GITHUB_TOKEN}}"
307+
279308 centos-stream-9-binaries :
280309 # Run if the ancestor jobs succeeded OR they were skipped and clp was changed.
281310 if : >-
@@ -455,7 +484,7 @@ jobs:
455484 || (!cancelled() && !failure() && needs.filter-relevant-changes.outputs.clp_changed == 'true')
456485 needs :
457486 - " filter-relevant-changes"
458- - " ubuntu-jammy-deps-image"
487+ - " ubuntu-jammy-x86_64- deps-image"
459488 strategy :
460489 matrix :
461490 include :
@@ -539,7 +568,7 @@ jobs:
539568 tar xf clp.tar
540569 rm clp.tar
541570
542- - uses : " docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 "
571+ - uses : " docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 " # v4.1.0
543572 with :
544573 registry : " ghcr.io"
545574 username : " ${{github.actor}}"
@@ -580,7 +609,7 @@ jobs:
580609 || (!cancelled() && !failure() && needs.filter-relevant-changes.outputs.clp_changed == 'true')
581610 needs :
582611 - " filter-relevant-changes"
583- - " ubuntu-jammy-deps-image"
612+ - " ubuntu-jammy-x86_64- deps-image"
584613 runs-on : *runner
585614 steps :
586615 - uses : " actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd" # v6.0.2
@@ -649,16 +678,35 @@ jobs:
649678 )}}
650679
651680 package-image :
652- name : " package-image"
681+ name : " package-image-${{matrix.arch}}"
682+ # NOTE: The aarch64 job is skipped on PRs, so we accept both 'success' and 'skipped'.
653683 if : >-
654684 !cancelled() && !failure() && (
655685 needs.filter-relevant-changes.outputs.ubuntu_jammy_image_changed == 'false' ||
656- needs.ubuntu-jammy-deps-image.result == 'success'
686+ (needs.ubuntu-jammy-x86_64-deps-image.result == 'success'
687+ && (needs.ubuntu-jammy-aarch64-deps-image.result == 'success'
688+ || needs.ubuntu-jammy-aarch64-deps-image.result == 'skipped'))
657689 )
658690 needs :
659691 - " filter-relevant-changes"
660- - " ubuntu-jammy-deps-image"
661- runs-on : *runner
692+ - " ubuntu-jammy-x86_64-deps-image"
693+ - " ubuntu-jammy-aarch64-deps-image"
694+ strategy :
695+ matrix :
696+ # Only build arm64 images on push to main to save CI resources on PRs.
697+ arch : >-
698+ ${{github.event_name != 'pull_request' && github.ref == 'refs/heads/main'
699+ && fromJSON('["amd64", "arm64"]') || fromJSON('["amd64"]')}}
700+ runs-on : >-
701+ ${{
702+ matrix.arch == 'amd64'
703+ && (github.repository_owner == 'y-scope'
704+ && fromJSON('["self-hosted", "x64", "ubuntu-noble"]')
705+ || 'ubuntu-24.04')
706+ || (github.repository_owner == 'y-scope'
707+ && fromJSON('["self-hosted", "arm64", "ubuntu-noble"]')
708+ || 'ubuntu-24.04-arm')
709+ }}
662710 steps :
663711 - uses : " actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd" # v6.0.2
664712 with :
@@ -673,7 +721,10 @@ jobs:
673721 env :
674722 OS_NAME : " ubuntu-jammy"
675723 with :
676- image_name : " ${{env.DEPS_IMAGE_NAME_PREFIX_X86}}${{env.OS_NAME}}"
724+ image_name : >-
725+ ${{format('{0}ubuntu-jammy',
726+ matrix.arch == 'amd64' && env.DEPS_IMAGE_NAME_PREFIX_X86
727+ || env.DEPS_IMAGE_NAME_PREFIX_AARCH64)}}
677728 use_published_image : >-
678729 ${{needs.filter-relevant-changes.outputs.ubuntu_jammy_image_changed == 'false'
679730 || (github.event_name != 'pull_request' && github.ref == 'refs/heads/main')}}
@@ -687,3 +738,42 @@ jobs:
687738 image_registry : " ghcr.io"
688739 image_registry_username : " ${{github.actor}}"
689740 image_registry_password : " ${{secrets.GITHUB_TOKEN}}"
741+ arch : " ${{matrix.arch}}"
742+
743+ package-image-multiarch-manifest :
744+ name : " package-image-multiarch-manifest"
745+ if : >-
746+ github.event_name != 'pull_request'
747+ && github.ref == 'refs/heads/main'
748+ && needs.package-image.result == 'success'
749+ needs : " package-image"
750+ runs-on : *runner
751+ steps :
752+ - name : " Login to Image Registry"
753+ uses : " docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121" # v4.1.0
754+ with :
755+ registry : " ghcr.io"
756+ username : " ${{github.actor}}"
757+ password : " ${{secrets.GITHUB_TOKEN}}"
758+
759+ - name : " Sanitize Repository Name"
760+ id : " sanitization"
761+ shell : " bash"
762+ run : |
763+ echo "REPOSITORY=$(echo '${{github.repository}}' | tr '[:upper:]' '[:lower:]')" \
764+ >> "$GITHUB_OUTPUT"
765+
766+ - name : " Create and Push Multi-arch Manifest"
767+ shell : " bash"
768+ run : |
769+ image_base="ghcr.io/${{steps.sanitization.outputs.REPOSITORY}}/clp-package"
770+ tags=("${{github.ref_name}}")
771+ if [ "${{github.event_name}}" = "schedule" ]; then
772+ tags+=("nightly")
773+ fi
774+ for tag in "${tags[@]}"; do
775+ docker manifest create "${image_base}:${tag}" \
776+ "${image_base}:${tag}-amd64" \
777+ "${image_base}:${tag}-arm64"
778+ docker manifest push "${image_base}:${tag}"
779+ done
0 commit comments