@@ -49,6 +49,9 @@ def main() -> None:
4949 print ("Migrating auto-dependabot workflow to use GitHub App token..." )
5050 migrate_auto_dependabot_token ()
5151 print ("=" * 72 )
52+ print ("Migrating the CI workflows to use a platform matrix..." )
53+ migrate_platform_matrix ()
54+ print ("=" * 72 )
5255 print ()
5356
5457 if _manual_steps :
@@ -465,6 +468,55 @@ def replace_setuptools_pin(content: str, new_version: str) -> tuple[str, bool]:
465468 return new_content , count > 0
466469
467470
471+ def migrate_platform_matrix () -> None :
472+ """Migrate CI matrix from arch+os to a single platform entry.
473+
474+ This replaces the old matrix definition that used separate `arch` and `os`
475+ entries with a single `platform` entry using GitHub's native arm64 runners
476+ that are now available to both public and private repositories.
477+ """
478+ workflow_file = Path (".github/workflows/ci.yaml" )
479+ print (f" - { workflow_file } " )
480+ if not workflow_file .is_file ():
481+ manual_step (
482+ f"Could not find { workflow_file } ; please manually migrate to use a"
483+ "please manually migrate to use a `platform` matrix entry."
484+ )
485+ return
486+
487+ content = workflow_file .read_text (encoding = "utf-8" )
488+ new_content = content
489+
490+ # Replace the arch+os matrix block with platform.
491+ # Handle both "arm" (old) and "arm64" (intermediate) variants.
492+ new_content = re .sub (
493+ r"( +)arch:\n\1 - amd64\n\1 - arm(?:64)?\n\1os:\n\1 - ubuntu-24\.04\n" ,
494+ r"\g<1>platform:\n\g<1> - ubuntu-24.04\n\g<1> - ubuntu-24.04-arm\n" ,
495+ new_content ,
496+ )
497+
498+ # Replace any runs-on expression referencing matrix.arch with the simpler
499+ # matrix.platform reference.
500+ new_content = re .sub (
501+ r"runs-on: \$\{\{.*matrix\.arch.*\}\}" ,
502+ "runs-on: ${{ matrix.platform }}" ,
503+ new_content ,
504+ )
505+
506+ if new_content == content :
507+ if "matrix.platform" in content :
508+ print (" Already uses platform matrix" )
509+ else :
510+ manual_step (
511+ f"Could not find arch+os matrix pattern in { workflow_file } ; "
512+ "please manually migrate to use a `platform` matrix entry."
513+ )
514+ return
515+
516+ replace_file_contents_atomically (workflow_file , content , new_content , count = 1 )
517+ print (" Migrated arch+os matrix to platform" )
518+
519+
468520def apply_patch (patch_content : str ) -> None :
469521 """Apply a patch using the patch utility."""
470522 subprocess .run (["patch" , "-p1" ], input = patch_content .encode (), check = True )
0 commit comments