-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The script is [currently failing with](https://github.com/pytest-dev/pytest/actions/runs/13615071695/job/38057071681): ``` remote: Support for password authentication was removed on August 13, 2021. remote: Please see https://docs.github.com/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication. fatal: Authentication failed for 'https://github.com/pytest-dev/pytest.git/' ``` Decided to remove the usage of `github3` and use the `gh` command-line tool directly, which simplifies the script, integrates nicely with GH, and enables to run it locally seamlessly.
- Loading branch information
1 parent
bc4abe4
commit 79f0733
Showing
3 changed files
with
21 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,8 +10,7 @@ | |
After that, it will create a release using the `release` tox environment, and push a new PR. | ||
**Token**: currently the token from the GitHub Actions is used, pushed with | ||
`pytest bot <[email protected]>` commit author. | ||
Note: the script uses the `gh` command-line tool, so `GH_TOKEN` must be set in the environment. | ||
""" | ||
|
||
from __future__ import annotations | ||
|
@@ -25,7 +24,6 @@ | |
|
||
from colorama import Fore | ||
from colorama import init | ||
from github3.repos import Repository | ||
|
||
|
||
class InvalidFeatureRelease(Exception): | ||
|
@@ -54,17 +52,7 @@ class InvalidFeatureRelease(Exception): | |
""" | ||
|
||
|
||
def login(token: str) -> Repository: | ||
import github3 | ||
|
||
github = github3.login(token=token) | ||
owner, repo = SLUG.split("/") | ||
return github.repository(owner, repo) | ||
|
||
|
||
def prepare_release_pr( | ||
base_branch: str, is_major: bool, token: str, prerelease: str | ||
) -> None: | ||
def prepare_release_pr(base_branch: str, is_major: bool, prerelease: str) -> None: | ||
print() | ||
print(f"Processing release for branch {Fore.CYAN}{base_branch}") | ||
|
||
|
@@ -131,22 +119,25 @@ def prepare_release_pr( | |
check=True, | ||
) | ||
|
||
oauth_url = f"https://{token}:[email protected]/{SLUG}.git" | ||
run( | ||
["git", "push", oauth_url, f"HEAD:{release_branch}", "--force"], | ||
["git", "push", "origin", f"HEAD:{release_branch}", "--force"], | ||
check=True, | ||
) | ||
print(f"Branch {Fore.CYAN}{release_branch}{Fore.RESET} pushed.") | ||
|
||
body = PR_BODY.format(version=version) | ||
repo = login(token) | ||
pr = repo.create_pull( | ||
f"Prepare release {version}", | ||
base=base_branch, | ||
head=release_branch, | ||
body=body, | ||
run( | ||
[ | ||
"gh", | ||
"pr", | ||
"new", | ||
f"--base={base_branch}", | ||
f"--head={release_branch}", | ||
f"--title=Release {version}", | ||
f"--body={body}", | ||
], | ||
check=True, | ||
) | ||
print(f"Pull request {Fore.CYAN}{pr.url}{Fore.RESET} created.") | ||
|
||
|
||
def find_next_version( | ||
|
@@ -174,14 +165,12 @@ def main() -> None: | |
init(autoreset=True) | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument("base_branch") | ||
parser.add_argument("token") | ||
parser.add_argument("--major", action="store_true", default=False) | ||
parser.add_argument("--prerelease", default="") | ||
options = parser.parse_args() | ||
prepare_release_pr( | ||
base_branch=options.base_branch, | ||
is_major=options.major, | ||
token=options.token, | ||
prerelease=options.prerelease, | ||
) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters