(
base_branch: str, is_major: bool, token: str, prerelease: str
)
| 47 | |
| 48 | |
| 49 | def prepare_release_pr( |
| 50 | base_branch: str, is_major: bool, token: str, prerelease: str |
| 51 | ) -> None: |
| 52 | print() |
| 53 | print(f"Processing release for branch {Fore.CYAN}{base_branch}") |
| 54 | |
| 55 | check_call(["git", "checkout", f"origin/{base_branch}"]) |
| 56 | |
| 57 | changelog = Path("changelog") |
| 58 | |
| 59 | features = list(changelog.glob("*.feature.rst")) |
| 60 | breaking = list(changelog.glob("*.breaking.rst")) |
| 61 | is_feature_release = bool(features or breaking) |
| 62 | |
| 63 | try: |
| 64 | version = find_next_version( |
| 65 | base_branch, is_major, is_feature_release, prerelease |
| 66 | ) |
| 67 | except InvalidFeatureRelease as e: |
| 68 | print(f"{Fore.RED}{e}") |
| 69 | raise SystemExit(1) |
| 70 | |
| 71 | print(f"Version: {Fore.CYAN}{version}") |
| 72 | |
| 73 | release_branch = f"release-{version}" |
| 74 | |
| 75 | run( |
| 76 | ["git", "config", "user.name", "pytest bot"], |
| 77 | check=True, |
| 78 | ) |
| 79 | run( |
| 80 | ["git", "config", "user.email", "pytestbot@gmail.com"], |
| 81 | check=True, |
| 82 | ) |
| 83 | |
| 84 | run( |
| 85 | ["git", "checkout", "-b", release_branch, f"origin/{base_branch}"], |
| 86 | check=True, |
| 87 | ) |
| 88 | |
| 89 | print(f"Branch {Fore.CYAN}{release_branch}{Fore.RESET} created.") |
| 90 | |
| 91 | if is_major: |
| 92 | template_name = "release.major.rst" |
| 93 | elif prerelease: |
| 94 | template_name = "release.pre.rst" |
| 95 | elif is_feature_release: |
| 96 | template_name = "release.minor.rst" |
| 97 | else: |
| 98 | template_name = "release.patch.rst" |
| 99 | |
| 100 | # important to use tox here because we have changed branches, so dependencies |
| 101 | # might have changed as well |
| 102 | cmdline = [ |
| 103 | "tox", |
| 104 | "-e", |
| 105 | "release", |
| 106 | "--", |
no test coverage detected