mirror of
https://github.com/element-hq/synapse.git
synced 2024-12-14 11:57:44 +00:00
Fix release script to check GH token (#17803)
Some checks failed
Tests / check-lockfile (push) Has been cancelled
Build docker images / build (push) Has been cancelled
Deploy the documentation / Calculate variables for GitHub Pages deployment (push) Has been cancelled
Build release artifacts / Calculate list of debian distros (push) Has been cancelled
Build release artifacts / Build wheels on ubuntu-20.04 for aarch64 (push) Has been cancelled
Build release artifacts / Build wheels on macos-12 for x86_64 (push) Has been cancelled
Build release artifacts / Build wheels on ubuntu-20.04 for x86_64 (push) Has been cancelled
Build release artifacts / Build sdist (push) Has been cancelled
Tests / changes (push) Has been cancelled
Tests / lint-crlf (push) Has been cancelled
Tests / lint-newsfile (push) Has been cancelled
Tests / lint (push) Has been cancelled
Tests / calculate-test-jobs (push) Has been cancelled
Deploy the documentation / GitHub Pages (push) Has been cancelled
Build release artifacts / Build .deb packages (push) Has been cancelled
Build release artifacts / Attach assets to release (push) Has been cancelled
Tests / check-schema-delta (push) Has been cancelled
Tests / check-sampleconfig (push) Has been cancelled
Tests / Typechecking (push) Has been cancelled
Tests / lint-pydantic (push) Has been cancelled
Tests / lint-clippy (push) Has been cancelled
Tests / lint-clippy-nightly (push) Has been cancelled
Tests / lint-rustfmt (push) Has been cancelled
Tests / lint-readme (push) Has been cancelled
Tests / linting-done (push) Has been cancelled
Tests / trial (push) Has been cancelled
Tests / trial-olddeps (push) Has been cancelled
Tests / trial-pypy (all, pypy-3.8) (push) Has been cancelled
Tests / sytest (push) Has been cancelled
Tests / export-data (push) Has been cancelled
Tests / portdb (11, 3.8) (push) Has been cancelled
Tests / portdb (15, 3.11) (push) Has been cancelled
Tests / complement (monolith, Postgres) (push) Has been cancelled
Tests / complement (monolith, SQLite) (push) Has been cancelled
Tests / complement (workers, Postgres) (push) Has been cancelled
Tests / cargo-test (push) Has been cancelled
Tests / cargo-bench (push) Has been cancelled
Tests / tests-done (push) Has been cancelled
Some checks failed
Tests / check-lockfile (push) Has been cancelled
Build docker images / build (push) Has been cancelled
Deploy the documentation / Calculate variables for GitHub Pages deployment (push) Has been cancelled
Build release artifacts / Calculate list of debian distros (push) Has been cancelled
Build release artifacts / Build wheels on ubuntu-20.04 for aarch64 (push) Has been cancelled
Build release artifacts / Build wheels on macos-12 for x86_64 (push) Has been cancelled
Build release artifacts / Build wheels on ubuntu-20.04 for x86_64 (push) Has been cancelled
Build release artifacts / Build sdist (push) Has been cancelled
Tests / changes (push) Has been cancelled
Tests / lint-crlf (push) Has been cancelled
Tests / lint-newsfile (push) Has been cancelled
Tests / lint (push) Has been cancelled
Tests / calculate-test-jobs (push) Has been cancelled
Deploy the documentation / GitHub Pages (push) Has been cancelled
Build release artifacts / Build .deb packages (push) Has been cancelled
Build release artifacts / Attach assets to release (push) Has been cancelled
Tests / check-schema-delta (push) Has been cancelled
Tests / check-sampleconfig (push) Has been cancelled
Tests / Typechecking (push) Has been cancelled
Tests / lint-pydantic (push) Has been cancelled
Tests / lint-clippy (push) Has been cancelled
Tests / lint-clippy-nightly (push) Has been cancelled
Tests / lint-rustfmt (push) Has been cancelled
Tests / lint-readme (push) Has been cancelled
Tests / linting-done (push) Has been cancelled
Tests / trial (push) Has been cancelled
Tests / trial-olddeps (push) Has been cancelled
Tests / trial-pypy (all, pypy-3.8) (push) Has been cancelled
Tests / sytest (push) Has been cancelled
Tests / export-data (push) Has been cancelled
Tests / portdb (11, 3.8) (push) Has been cancelled
Tests / portdb (15, 3.11) (push) Has been cancelled
Tests / complement (monolith, Postgres) (push) Has been cancelled
Tests / complement (monolith, SQLite) (push) Has been cancelled
Tests / complement (workers, Postgres) (push) Has been cancelled
Tests / cargo-test (push) Has been cancelled
Tests / cargo-bench (push) Has been cancelled
Tests / tests-done (push) Has been cancelled
The current logic didn't work.
This commit is contained in:
parent
05576f0b4b
commit
f6a3e5e1c2
2 changed files with 24 additions and 13 deletions
1
changelog.d/17803.misc
Normal file
1
changelog.d/17803.misc
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Test github token before running release script steps.
|
|
@ -40,7 +40,7 @@ import commonmark
|
||||||
import git
|
import git
|
||||||
from click.exceptions import ClickException
|
from click.exceptions import ClickException
|
||||||
from git import GitCommandError, Repo
|
from git import GitCommandError, Repo
|
||||||
from github import Github
|
from github import BadCredentialsException, Github
|
||||||
from packaging import version
|
from packaging import version
|
||||||
|
|
||||||
|
|
||||||
|
@ -323,10 +323,8 @@ def tag(gh_token: Optional[str]) -> None:
|
||||||
def _tag(gh_token: Optional[str]) -> None:
|
def _tag(gh_token: Optional[str]) -> None:
|
||||||
"""Tags the release and generates a draft GitHub release"""
|
"""Tags the release and generates a draft GitHub release"""
|
||||||
|
|
||||||
if gh_token:
|
# Test that the GH Token is valid before continuing.
|
||||||
# Test that the GH Token is valid before continuing.
|
check_valid_gh_token(gh_token)
|
||||||
gh = Github(gh_token)
|
|
||||||
gh.get_user()
|
|
||||||
|
|
||||||
# Make sure we're in a git repo.
|
# Make sure we're in a git repo.
|
||||||
repo = get_repo_and_check_clean_checkout()
|
repo = get_repo_and_check_clean_checkout()
|
||||||
|
@ -469,10 +467,8 @@ def upload(gh_token: Optional[str]) -> None:
|
||||||
def _upload(gh_token: Optional[str]) -> None:
|
def _upload(gh_token: Optional[str]) -> None:
|
||||||
"""Upload release to pypi."""
|
"""Upload release to pypi."""
|
||||||
|
|
||||||
if gh_token:
|
# Test that the GH Token is valid before continuing.
|
||||||
# Test that the GH Token is valid before continuing.
|
check_valid_gh_token(gh_token)
|
||||||
gh = Github(gh_token)
|
|
||||||
gh.get_user()
|
|
||||||
|
|
||||||
current_version = get_package_version()
|
current_version = get_package_version()
|
||||||
tag_name = f"v{current_version}"
|
tag_name = f"v{current_version}"
|
||||||
|
@ -569,10 +565,8 @@ def wait_for_actions(gh_token: Optional[str]) -> None:
|
||||||
|
|
||||||
|
|
||||||
def _wait_for_actions(gh_token: Optional[str]) -> None:
|
def _wait_for_actions(gh_token: Optional[str]) -> None:
|
||||||
if gh_token:
|
# Test that the GH Token is valid before continuing.
|
||||||
# Test that the GH Token is valid before continuing.
|
check_valid_gh_token(gh_token)
|
||||||
gh = Github(gh_token)
|
|
||||||
gh.get_user()
|
|
||||||
|
|
||||||
# Find out the version and tag name.
|
# Find out the version and tag name.
|
||||||
current_version = get_package_version()
|
current_version = get_package_version()
|
||||||
|
@ -806,6 +800,22 @@ def get_repo_and_check_clean_checkout(
|
||||||
return repo
|
return repo
|
||||||
|
|
||||||
|
|
||||||
|
def check_valid_gh_token(gh_token: Optional[str]) -> None:
|
||||||
|
"""Check that a github token is valid, if supplied"""
|
||||||
|
|
||||||
|
if not gh_token:
|
||||||
|
# No github token supplied, so nothing to do.
|
||||||
|
return
|
||||||
|
|
||||||
|
try:
|
||||||
|
gh = Github(gh_token)
|
||||||
|
|
||||||
|
# We need to lookup name to trigger a request.
|
||||||
|
_name = gh.get_user().name
|
||||||
|
except BadCredentialsException as e:
|
||||||
|
raise click.ClickException(f"Github credentials are bad: {e}")
|
||||||
|
|
||||||
|
|
||||||
def find_ref(repo: git.Repo, ref_name: str) -> Optional[git.HEAD]:
|
def find_ref(repo: git.Repo, ref_name: str) -> Optional[git.HEAD]:
|
||||||
"""Find the branch/ref, looking first locally then in the remote."""
|
"""Find the branch/ref, looking first locally then in the remote."""
|
||||||
if ref_name in repo.references:
|
if ref_name in repo.references:
|
||||||
|
|
Loading…
Reference in a new issue