Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
blink1073 committed Sep 12, 2022
1 parent e5b6d4f commit 2d9fc9f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
3 changes: 3 additions & 0 deletions jupyter_releaser/actions/draft_release.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ""

Expand Down
12 changes: 11 additions & 1 deletion jupyter_releaser/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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


Expand Down Expand Up @@ -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.
Expand All @@ -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():
Expand Down

0 comments on commit 2d9fc9f

Please sign in to comment.