def main()

in scripts/publish_crates_io.py [0:0]


def main(args):
    if not args.dry_run and not is_logged_in():
        print("Please run `cargo login` first and then retry")
        return 1

    print(
        """The script is a little hacky and not yet idempotent. So if any
crate upload fails you may need to delete already-uploaded packages
from `PACKAGES` and restart the script
"""
    )

    repo_root = get_repository_root()
    for package in PACKAGES:
        crate_root = f"{repo_root}/{package}"
        print(f"++ Publishing {crate_root}")
        publish_crate(crate_root, args.dry_run)

        # HACK: wait for crates.io to stabilize previously uploaded deps
        print("++ Waiting for crates.io to stabilize")
        time.sleep(30)

    return 0