diff --git a/c2cciutils/publish.py b/c2cciutils/publish.py index ef6745cbf..0a90156b2 100644 --- a/c2cciutils/publish.py +++ b/c2cciutils/publish.py @@ -337,7 +337,6 @@ def docker( image_config: c2cciutils.configuration.PublishDockerImage, tag_src: str, tag_dst: str, - latest: bool, alt_tags: list[str], images_full: list[str], ) -> bool: @@ -378,17 +377,6 @@ def docker( check=True, ) new_images_full.append(f"{config['server']}/{image_config['name']}:{tag_dst}") - if latest: - subprocess.run( - [ - "docker", - "tag", - f"{image_config['name']}:{tag_src}", - f"{config['server']}/{image_config['name']}:{tag_src}", - ], - check=True, - ) - new_images_full.append(f"{config['server']}/{image_config['name']}:{tag_src}") for alt_tag in alt_tags: subprocess.run( [ @@ -412,18 +400,17 @@ def docker( check=True, ) new_images_full.append(f"{image_config['name']}:{tag_dst}") - if latest and tag_src != tag_dst: - new_images_full.append(f"{image_config['name']}:{tag_src}") for alt_tag in alt_tags: - subprocess.run( - [ - "docker", - "tag", - f"{image_config['name']}:{tag_src}", - f"{image_config['name']}:{alt_tag}", - ], - check=True, - ) + if tag_src != alt_tag: + subprocess.run( + [ + "docker", + "tag", + f"{image_config['name']}:{tag_src}", + f"{image_config['name']}:{alt_tag}", + ], + check=True, + ) new_images_full.append(f"{image_config['name']}:{alt_tag}") for image in new_images_full: diff --git a/c2cciutils/scripts/publish.py b/c2cciutils/scripts/publish.py index 4dad2fd31..e80b458f4 100644 --- a/c2cciutils/scripts/publish.py +++ b/c2cciutils/scripts/publish.py @@ -193,7 +193,6 @@ def main() -> None: config.get("publish", {}).get("docker", {}) if config.get("publish", {}).get("docker", False) else {}, ) if docker_config: - latest = False full_repo = c2cciutils.get_repository() full_repo_split = full_repo.split("/") master_branch, _ = c2cciutils.get_master_branch(full_repo_split) @@ -216,7 +215,6 @@ def main() -> None: security = c2cciutils.security.Security(security_text) version_index = security.headers.index("Version") - latest = security.data[-1][version_index] == version row_index = -1 for index, row in enumerate(security.data): @@ -224,10 +222,12 @@ def main() -> None: row_index = index break - alt_tags = [] + alt_tags = set() if "Alternate Tag" in security.headers: tag_index = security.headers.index("Alternate Tag") - alt_tags = security.data[row_index][tag_index].split(",") + alt_tags = {t.strip() for t in security.data[row_index][tag_index].split(",")} + if security.data[-1][version_index] == version: + alt_tags.add("latest") images_src: set[str] = set() images_full: list[str] = [] @@ -285,22 +285,13 @@ def main() -> None: if args.dry_run: print(f"Publishing {image_dst} to {name}, skipping (dry run)") - if latest: - print(f"Publishing {image_source} to {name}, skipping (dry run)") for alt_tag in current_alt_tag: print( f"Publishing {image_conf['name']}:{alt_tag} to {name}, skipping (dry run)" ) else: success &= c2cciutils.publish.docker( - conf, - name, - image_conf, - tag_src, - tag_dst, - latest, - current_alt_tag, - images_full, + conf, name, image_conf, tag_src, tag_dst, current_alt_tag, images_full ) if google_calendar_publish: