From a092d2053ad073512c7ff407c2d8bf495c46777a Mon Sep 17 00:00:00 2001 From: Andrew Morgan <1342360+anoadragon453@users.noreply.github.com> Date: Fri, 24 Oct 2025 12:19:04 +0200 Subject: [PATCH] Fix deprecation warning in release script (#19080) --- changelog.d/19080.misc | 1 + scripts-dev/release.py | 16 +++++++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) create mode 100644 changelog.d/19080.misc diff --git a/changelog.d/19080.misc b/changelog.d/19080.misc new file mode 100644 index 000000000..c738be3fe --- /dev/null +++ b/changelog.d/19080.misc @@ -0,0 +1 @@ +Update deprecated code in the release script to prevent a warning message from being printed. \ No newline at end of file diff --git a/scripts-dev/release.py b/scripts-dev/release.py index c20237eab..111c184cc 100755 --- a/scripts-dev/release.py +++ b/scripts-dev/release.py @@ -38,6 +38,7 @@ import attr import click import git import github +import github.Auth from click.exceptions import ClickException from git import GitCommandError, Repo from github import BadCredentialsException, Github @@ -429,7 +430,7 @@ def _publish(gh_token: str) -> None: if gh_token: # Test that the GH Token is valid before continuing. - gh = Github(gh_token) + gh = Github(auth=github.Auth.Token(token=gh_token)) gh.get_user() # Make sure we're in a git repo. @@ -442,7 +443,7 @@ def _publish(gh_token: str) -> None: return # Publish the draft release - gh = Github(gh_token) + gh = Github(auth=github.Auth.Token(token=gh_token)) gh_repo = gh.get_repo("element-hq/synapse") for release in gh_repo.get_releases(): if release.title == tag_name: @@ -487,8 +488,13 @@ def _upload(gh_token: Optional[str]) -> None: click.echo(f"Tag {tag_name} ({tag.commit}) is not currently checked out!") click.get_current_context().abort() + if gh_token: + gh = Github(auth=github.Auth.Token(token=gh_token)) + else: + # Use github anonymously. + gh = Github() + # Query all the assets corresponding to this release. - gh = Github(gh_token) gh_repo = gh.get_repo("element-hq/synapse") gh_release = gh_repo.get_release(tag_name) @@ -764,7 +770,7 @@ Ask the designated people to do the blog and tweets.""" def full(gh_token: str) -> None: if gh_token: # Test that the GH Token is valid before continuing. - gh = Github(gh_token) + gh = Github(auth=github.Auth.Token(token=gh_token)) gh.get_user() click.echo("1. If this is a security release, read the security wiki page.") @@ -850,7 +856,7 @@ def check_valid_gh_token(gh_token: Optional[str]) -> None: return try: - gh = Github(gh_token) + gh = Github(auth=github.Auth.Token(token=gh_token)) # We need to lookup name to trigger a request. _name = gh.get_user().name