Create and checkout release branch.
(new_version: str)
| 477 | |
| 478 | |
| 479 | def create_release_branch(new_version: str) -> str: |
| 480 | """Create and checkout release branch.""" |
| 481 | branch_name = f"release/v{new_version}" |
| 482 | |
| 483 | print(f"🌿 Creating release branch: {branch_name}") |
| 484 | |
| 485 | # Check if branch already exists |
| 486 | try: |
| 487 | run_cmd(f"git rev-parse --verify {branch_name}", capture_output=True) |
| 488 | print(f"⚠️ Branch {branch_name} already exists") |
| 489 | choice = input( |
| 490 | " Do you want to (d)elete and recreate, (c)heckout existing, or (a)bort? [d/c/a]: " |
| 491 | ) |
| 492 | |
| 493 | if choice.lower() == "d": |
| 494 | run_cmd(f"git branch -D {branch_name}") |
| 495 | run_cmd(f"git checkout -b {branch_name}") |
| 496 | elif choice.lower() == "c": |
| 497 | run_cmd(f"git checkout {branch_name}") |
| 498 | else: |
| 499 | sys.exit("❌ Release cancelled") |
| 500 | except subprocess.CalledProcessError: |
| 501 | # Branch doesn't exist, create it |
| 502 | run_cmd(f"git checkout -b {branch_name}") |
| 503 | |
| 504 | print(f"✅ On release branch: {branch_name}") |
| 505 | return branch_name |
| 506 | |
| 507 | |
| 508 | def run_version_bump(bump_type: str): |