def validate_tags_and_releases()

in tools/release/release-verify.py [0:0]


def validate_tags_and_releases(repo_paths, lib_versions):
    """
    Validates that each library repo has a release and tag for the specified version number.
    Args:
        repo_paths (dict): Paths to all library repos in the CSDK, including their org.
        lib_versions (dict): A dictionary containing the new versions of each library.
    """
    if not GITHUB_RELEASES_TAGS_VERIFY:
        return
    # Verify that all repos have a release and tag for the version specified in the config.
    for repo_path in repo_paths:
        library = repo_path.split("/")[-1].casefold()
        # Only need to verify for spoke repos because CSDK is the library being released.
        if library == CSDK_REPO:
            continue
        # Check that a release exists with the same name as the version.
        git_releases_resp = requests.get(f"{GITHUB_API_URL}/repos/{repo_path}/releases", headers=GITHUB_AUTH_HEADER)
        found_release_for_version = False
        for release in git_releases_resp.json():
            if release["name"] == lib_versions[library] and release["tag_name"] == lib_versions[library]:
                found_release_for_version = True
                break
        if not found_release_for_version:
            log_error(f"Could not find release {lib_versions[library]} for {repo_path}.")
        # Check that a tag exists with the same name as the version.
        git_tags_resp = requests.get(f"{GITHUB_API_URL}/repos/{repo_path}/tags", headers=GITHUB_AUTH_HEADER)
        found_tag_for_version = False
        for tag in git_tags_resp.json():
            if tag["name"] == lib_versions[library]:
                found_tag_for_version = True
                break
        if not found_tag_for_version:
            log_error(f"Could not find tag {lib_versions[library]} for {repo_path}.")