@@ -78,38 +78,27 @@ def pull_missing_tags(merged_tag: str, all_local_tags: list[str]) -> list[str]:
7878 return existing_platform_tags
7979
8080
81- @retry (stop = stop_after_attempt (3 ), wait = wait_exponential (multiplier = 1 , min = 4 ))
82- def create_manifest (merged_tag : str , existing_platform_tags : list [str ]) -> None :
83- # This allows to rerun the script without having to remove the manifest manually
84- try :
85- docker ["manifest" , "rm" , merged_tag ] & plumbum .FG
86- LOGGER .warning (f"Manifest { merged_tag } was present locally, removed it" )
87- except plumbum .ProcessExecutionError :
88- pass
89-
90- LOGGER .info (f"Creating manifest for tag: { merged_tag } " )
91- # Unfortunately, `docker manifest create` requires images to have been already pushed to the registry
92- # which is not true for new tags in PRs
93- docker ["manifest" , "create" , merged_tag ][existing_platform_tags ] & plumbum .FG
94- LOGGER .info (f"Successfully created manifest for tag: { merged_tag } " )
95-
96-
97- @retry (stop = stop_after_attempt (3 ), wait = wait_exponential (multiplier = 1 , min = 4 ))
98- def push_manifest (merged_tag : str ) -> None :
99- LOGGER .info (f"Pushing manifest for tag: { merged_tag } " )
100- docker ["manifest" , "push" , merged_tag ] & plumbum .FG
101- LOGGER .info (f"Successfully pushed manifest for tag: { merged_tag } " )
102-
103-
10481def merge_tags (
10582 merged_tag : str , all_local_tags : list [str ], push_to_registry : bool
10683) -> None :
10784 LOGGER .info (f"Trying to merge tag: { merged_tag } " )
10885
10986 existing_platform_tags = pull_missing_tags (merged_tag , all_local_tags )
87+ args = [
88+ "buildx" ,
89+ "imagetools" ,
90+ "create" ,
91+ * existing_platform_tags ,
92+ "--tag" ,
93+ merged_tag ,
94+ ]
95+ if not push_to_registry :
96+ args .append ("--dry-run" )
97+
98+ LOGGER .info (f"Running command: { ' ' .join (args )} " )
99+ docker [args ] & plumbum .FG
110100 if push_to_registry :
111- create_manifest (merged_tag , existing_platform_tags )
112- push_manifest (merged_tag )
101+ LOGGER .info (f"Pushed merged tag: { merged_tag } to registry" )
113102 else :
114103 LOGGER .info (f"Skipping push for tag: { merged_tag } " )
115104
0 commit comments