Skip to content

Commit a5d25bb

Browse files
authored
Test github token before running release script (#17562)
This stops people from getting half way through a step and it failing due to the github token having expired (this happens to me every damn time).
1 parent f162c92 commit a5d25bb

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

changelog.d/17562.misc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Test github token before running release script steps.

scripts-dev/release.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,11 @@ def tag(gh_token: Optional[str]) -> None:
324324
def _tag(gh_token: Optional[str]) -> None:
325325
"""Tags the release and generates a draft GitHub release"""
326326

327+
if gh_token:
328+
# Test that the GH Token is valid before continuing.
329+
gh = Github(gh_token)
330+
gh.get_user()
331+
327332
# Make sure we're in a git repo.
328333
repo = get_repo_and_check_clean_checkout()
329334

@@ -418,6 +423,11 @@ def publish(gh_token: str) -> None:
418423
def _publish(gh_token: str) -> None:
419424
"""Publish release on GitHub."""
420425

426+
if gh_token:
427+
# Test that the GH Token is valid before continuing.
428+
gh = Github(gh_token)
429+
gh.get_user()
430+
421431
# Make sure we're in a git repo.
422432
get_repo_and_check_clean_checkout()
423433

@@ -460,6 +470,11 @@ def upload(gh_token: Optional[str]) -> None:
460470
def _upload(gh_token: Optional[str]) -> None:
461471
"""Upload release to pypi."""
462472

473+
if gh_token:
474+
# Test that the GH Token is valid before continuing.
475+
gh = Github(gh_token)
476+
gh.get_user()
477+
463478
current_version = get_package_version()
464479
tag_name = f"v{current_version}"
465480

@@ -555,6 +570,11 @@ def wait_for_actions(gh_token: Optional[str]) -> None:
555570

556571

557572
def _wait_for_actions(gh_token: Optional[str]) -> None:
573+
if gh_token:
574+
# Test that the GH Token is valid before continuing.
575+
gh = Github(gh_token)
576+
gh.get_user()
577+
558578
# Find out the version and tag name.
559579
current_version = get_package_version()
560580
tag_name = f"v{current_version}"
@@ -711,6 +731,11 @@ def _announce() -> None:
711731
@cli.command()
712732
@click.option("--gh-token", envvar=["GH_TOKEN", "GITHUB_TOKEN"], required=True)
713733
def full(gh_token: str) -> None:
734+
if gh_token:
735+
# Test that the GH Token is valid before continuing.
736+
gh = Github(gh_token)
737+
gh.get_user()
738+
714739
click.echo("1. If this is a security release, read the security wiki page.")
715740
click.echo("2. Check for any release blockers before proceeding.")
716741
click.echo(" https://github.com/element-hq/synapse/labels/X-Release-Blocker")

0 commit comments

Comments
 (0)