From 2d9fc9f8686398a45c602052f3f90d53d31e36e6 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Mon, 12 Sep 2022 10:12:06 -0500 Subject: [PATCH] cleanup --- jupyter_releaser/actions/draft_release.py | 3 +++ jupyter_releaser/util.py | 12 +++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/jupyter_releaser/actions/draft_release.py b/jupyter_releaser/actions/draft_release.py index 1cf3df85..1acf845c 100644 --- a/jupyter_releaser/actions/draft_release.py +++ b/jupyter_releaser/actions/draft_release.py @@ -12,6 +12,9 @@ setup() +if not os.environ.get("RH_RELEASE_URL"): + raise RuntimeError("Cannot complete Draft Release, no draft GitHub release url found!") + changelog_location = None changelog_text = "" diff --git a/jupyter_releaser/util.py b/jupyter_releaser/util.py index 33fe5f9b..29b8d3d4 100644 --- a/jupyter_releaser/util.py +++ b/jupyter_releaser/util.py @@ -341,6 +341,10 @@ def latest_draft_release(gh, branch=None): """Get the latest draft release for a given repo""" newest_time = None newest_release = None + if branch: + log(f"Getting latest draft release on branch {branch}") + else: + log("Getting latest draft release") for release in gh.repos.list_releases(): if str(release.draft).lower() == "false": continue @@ -351,6 +355,10 @@ def latest_draft_release(gh, branch=None): if newest_time is None or d_created > newest_time: newest_time = d_created newest_release = release + if not newest_release: + log("No draft release found!") + else: + log(f"Found draft release at {newest_release.html_url}") return newest_release @@ -511,8 +519,9 @@ def prepare_environment(): # Set up GitHub object. branch = os.environ.get("RH_BRANCH") - owner, repo_name = os.environ["GITHUB_REPOSITORY"].split("/") + owner, repo_name = os.environ["RH_REPOSITORY"].split("/") auth = os.environ.get("GITHUB_ACCESS_TOKEN", "") + log(f"Getting GitHub connection for {owner}/{repo_name}") gh = get_gh_object(dry_run=dry_run, owner=owner, repo=repo_name, token=auth) # Get the latest draft release if none is given. @@ -528,6 +537,7 @@ def prepare_environment(): # Extract the metadata from the release url. return extract_metadata_from_release_url(gh, release_url, auth) + return release_url def handle_since():