|
10 | 10 |
|
11 | 11 | After that, it will create a release using the `release` tox environment, and push a new PR.
|
12 | 12 |
|
13 |
| -**Token**: currently the token from the GitHub Actions is used, pushed with |
14 |
| -`pytest bot <pytestbot@gmail.com>` commit author. |
| 13 | +Note: the script uses the `gh` command-line tool, so `GH_TOKEN` must be set in the environment. |
15 | 14 | """
|
16 | 15 |
|
17 | 16 | from __future__ import annotations
|
|
25 | 24 |
|
26 | 25 | from colorama import Fore
|
27 | 26 | from colorama import init
|
28 |
| -from github3.repos import Repository |
29 | 27 |
|
30 | 28 |
|
31 | 29 | class InvalidFeatureRelease(Exception):
|
@@ -54,17 +52,7 @@ class InvalidFeatureRelease(Exception):
|
54 | 52 | """
|
55 | 53 |
|
56 | 54 |
|
57 |
| -def login(token: str) -> Repository: |
58 |
| - import github3 |
59 |
| - |
60 |
| - github = github3.login(token=token) |
61 |
| - owner, repo = SLUG.split("/") |
62 |
| - return github.repository(owner, repo) |
63 |
| - |
64 |
| - |
65 |
| -def prepare_release_pr( |
66 |
| - base_branch: str, is_major: bool, token: str, prerelease: str |
67 |
| -) -> None: |
| 55 | +def prepare_release_pr(base_branch: str, is_major: bool, prerelease: str) -> None: |
68 | 56 | print()
|
69 | 57 | print(f"Processing release for branch {Fore.CYAN}{base_branch}")
|
70 | 58 |
|
@@ -131,22 +119,25 @@ def prepare_release_pr(
|
131 | 119 | check=True,
|
132 | 120 | )
|
133 | 121 |
|
134 |
| - oauth_url = f"https://{token}:x-oauth-basic@github.com/{SLUG}.git" |
135 | 122 | run(
|
136 |
| - ["git", "push", oauth_url, f"HEAD:{release_branch}", "--force"], |
| 123 | + ["git", "push", "origin", f"HEAD:{release_branch}", "--force"], |
137 | 124 | check=True,
|
138 | 125 | )
|
139 | 126 | print(f"Branch {Fore.CYAN}{release_branch}{Fore.RESET} pushed.")
|
140 | 127 |
|
141 | 128 | body = PR_BODY.format(version=version)
|
142 |
| - repo = login(token) |
143 |
| - pr = repo.create_pull( |
144 |
| - f"Prepare release {version}", |
145 |
| - base=base_branch, |
146 |
| - head=release_branch, |
147 |
| - body=body, |
| 129 | + run( |
| 130 | + [ |
| 131 | + "gh", |
| 132 | + "pr", |
| 133 | + "new", |
| 134 | + f"--base={base_branch}", |
| 135 | + f"--head={release_branch}", |
| 136 | + f"--title=Release {version}", |
| 137 | + f"--body={body}", |
| 138 | + ], |
| 139 | + check=True, |
148 | 140 | )
|
149 |
| - print(f"Pull request {Fore.CYAN}{pr.url}{Fore.RESET} created.") |
150 | 141 |
|
151 | 142 |
|
152 | 143 | def find_next_version(
|
@@ -174,14 +165,12 @@ def main() -> None:
|
174 | 165 | init(autoreset=True)
|
175 | 166 | parser = argparse.ArgumentParser()
|
176 | 167 | parser.add_argument("base_branch")
|
177 |
| - parser.add_argument("token") |
178 | 168 | parser.add_argument("--major", action="store_true", default=False)
|
179 | 169 | parser.add_argument("--prerelease", default="")
|
180 | 170 | options = parser.parse_args()
|
181 | 171 | prepare_release_pr(
|
182 | 172 | base_branch=options.base_branch,
|
183 | 173 | is_major=options.major,
|
184 |
| - token=options.token, |
185 | 174 | prerelease=options.prerelease,
|
186 | 175 | )
|
187 | 176 |
|
|
0 commit comments