def post()

in scripts/release.py [0:0]


def post() -> None:
    # Ensure we have inputs
    next_version = os.getenv("NEXT_VERSION")
    if not next_version:
        return print(
            "You must define `NEXT_VERSION` environment variable", file=sys.stderr
        )
    if not re.match(r"(\d){1,2}\.(\d){1,2}\.(\d){1,2}-dev", next_version):
        return print("The `NEXT_VERSION` should match semver format.", file=sys.stderr)

    # Create a new branch
    # TODO: if you change the branch_name, please update the
    #       condition at .github/workflows/ci.yml
    branch_name = f"feat/post-release-v{next_version}"
    git = detect_git()
    git("checkout", "-b", branch_name, _out=sys.stdout, _err=sys.stderr)

    # Update all files
    __set_version(next_version)

    # Push changes
    git("add", "--all", _out=sys.stdout, _err=sys.stderr)
    git(
        "commit",
        "-m",
        "chore: prepare for next iteration",
        "--no-verify",
        _out=sys.stdout,
        _err=sys.stderr,
    )
    git("push", "origin", branch_name, _out=sys.stdout, _err=sys.stderr)

    # Create a PR
    gh = detect_gh()
    gh(
        "pr",
        "create",
        "--fill",
        "--base=main",
        f"--head={branch_name}",
        _out=sys.stdout,
        _err=sys.stderr,
    )