Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Store ref in metadata file #375

Merged
merged 5 commits into from
Sep 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
1 change: 1 addition & 0 deletions jupyter_releaser/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,7 @@ def draft_changelog(
"""Create a changelog entry PR"""
lib.draft_changelog(
version_spec,
ref,
branch,
repo,
since,
Expand Down
2 changes: 2 additions & 0 deletions jupyter_releaser/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ def check_links(ignore_glob, ignore_links, cache_file, links_expire):

def draft_changelog(
version_spec,
ref,
branch,
repo,
since,
Expand Down Expand Up @@ -157,6 +158,7 @@ def draft_changelog(

data = dict(
version_spec=version_spec,
ref=ref,
branch=branch,
repo=repo,
since=since,
Expand Down
20 changes: 17 additions & 3 deletions 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 @@ -469,6 +477,8 @@ def extract_metadata_from_release_url(gh, release_url, auth):
os.environ["RH_BRANCH"] = data["branch"]
if "since" in data:
os.environ["RH_SINCE"] = data["since"]
if "ref" in data:
os.environ["RH_REF"] = data["ref"]
if "since_last_stable" in data:
os.environ["RH_SINCE_LAST_STABLE"] = str(data["since_last_stable"])

Expand All @@ -479,8 +489,10 @@ def prepare_environment():
"""Prepare the environment variables, for use when running one of the
action scripts."""
# Set up env variables
os.environ.setdefault("RH_REPOSITORY", os.environ["GITHUB_REPOSITORY"])
os.environ.setdefault("RH_REF", os.environ["GITHUB_REF"])
if not os.environ.get("RH_REPOSITORY"):
os.environ["RH_REPOSITORY"] = os.environ["GITHUB_REPOSITORY"]
if not os.environ.get("RH_REF"):
os.environ["RH_REF"] = os.environ["GITHUB_REF"]

check_release = os.environ.get("RH_IS_CHECK_RELEASE", "").lower() == "true"
if not os.environ.get("RH_DRY_RUN") and check_release:
Expand Down Expand Up @@ -509,7 +521,8 @@ def prepare_environment():

# Set up GitHub object.
branch = os.environ.get("RH_BRANCH")
owner, repo_name = os.environ["GITHUB_REPOSITORY"].split("/")
log(f"Getting GitHub connection for {os.environ['RH_REPOSITORY']}")
owner, repo_name = os.environ["RH_REPOSITORY"].split("/")
auth = os.environ.get("GITHUB_ACCESS_TOKEN", "")
gh = get_gh_object(dry_run=dry_run, owner=owner, repo=repo_name, token=auth)

Expand All @@ -526,6 +539,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