Run the release preparation workflow. Args: argv: Optional command-line arguments for tests or programmatic calls. Returns: Process exit code.
(argv: list[str] | None = None)
| 430 | |
| 431 | |
| 432 | def main(argv: list[str] | None = None) -> int: |
| 433 | """Run the release preparation workflow. |
| 434 | |
| 435 | Args: |
| 436 | argv: Optional command-line arguments for tests or programmatic calls. |
| 437 | |
| 438 | Returns: |
| 439 | Process exit code. |
| 440 | """ |
| 441 | try: |
| 442 | args = parse_args(sys.argv[1:] if argv is None else argv) |
| 443 | version = validate_version(args.version) |
| 444 | ensure_clean_worktree() |
| 445 | |
| 446 | branch = create_release_branch(version, args.base_branch, args.remote) |
| 447 | tag = latest_tag() |
| 448 | if tag: |
| 449 | print(f"Latest tag: {tag}") |
| 450 | else: |
| 451 | print("No existing tags found; changelog will use all reachable commits.") |
| 452 | |
| 453 | commits = release_commits(tag) |
| 454 | update_pyproject_version(version) |
| 455 | update_package_version(version) |
| 456 | changelog_path = write_changelog(version, commits) |
| 457 | run_validation(args) |
| 458 | |
| 459 | if args.commit: |
| 460 | commit_and_maybe_push(version, branch, changelog_path, args) |
| 461 | |
| 462 | print_next_steps(version, branch, changelog_path, args) |
| 463 | return 0 |
| 464 | except ReleaseError as exc: |
| 465 | print(f"prepare-release: {exc}", file=sys.stderr) |
| 466 | return 1 |
| 467 | |
| 468 | |
| 469 | if __name__ == "__main__": |
no test coverage detected