Skip to content

Commit

Permalink
Merge pull request #223 from blink1073/default-branch
Browse files Browse the repository at this point in the history
Make branch and version spec optional
  • Loading branch information
jtpio authored Dec 13, 2021
2 parents 18d0a59 + fa8749a commit ea0e6d7
Show file tree
Hide file tree
Showing 10 changed files with 10 additions and 34 deletions.
4 changes: 0 additions & 4 deletions .github/workflows/draft-changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,12 @@ on:
required: true
branch:
description: "The branch to target"
required: true
version_spec:
description: "New Version Spec"
required: true
since:
description: Use PRs with activity since this date or git reference
required: false
since_last_stable:
description: Use PRs with activity since the last stable git tag
required: false
jobs:
draft_changelog:
runs-on: ubuntu-latest
Expand Down
6 changes: 0 additions & 6 deletions .github/workflows/draft-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,16 @@ on:
required: true
branch:
description: "The branch to target"
required: true
version_spec:
description: "New Version Specifier"
required: true
post_version_spec:
description: "Post Version Specifier"
required: false
since:
description: Use PRs with activity since this date or git reference
required: false
since_last_stable:
description: Use PRs with activity since the last stable git tag
required: false
steps_to_skip:
description: Comma separated list of steps to skip
required: false
jobs:
draft_release:
runs-on: ubuntu-latest
Expand Down
6 changes: 0 additions & 6 deletions .github/workflows/full-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,16 @@ on:
required: true
branch:
description: "The branch to target"
required: true
version_spec:
description: "New Version Specifier"
required: true
post_version_spec:
description: "Post Version Specifier"
required: false
since:
description: Use PRs with activity since this date or git reference
required: false
since_last_stable:
description: Use PRs with activity since the last stable git tag
required: false
steps_to_skip:
description: Comma separated list of steps to skip
required: false

jobs:
full_release:
Expand Down
4 changes: 0 additions & 4 deletions .github/workflows/generate-changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,12 @@ on:
required: true
branch:
description: The branch or reference name to filter pull requests by
required: true
convert_to_rst:
description: Whether to convert to RST
required: false
since:
description: Use PRs with activity since this date or git reference
required: false
until:
description: Use PRs with activity until this date or git reference
required: false
jobs:
generate_changelog:
runs-on: ubuntu-latest
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ on:
description: "The URL of the draft GitHub release"
required: true
steps_to_skip:
description: comma-separated list of steps to steps_to_skip
required: false
description: comma-separated list of steps to skip
jobs:
publish_release:
runs-on: ubuntu-latest
Expand Down
3 changes: 2 additions & 1 deletion jupyter_releaser/actions/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ def setup():
os.environ.setdefault("RH_REPOSITORY", os.environ["GITHUB_REPOSITORY"])
os.environ.setdefault("RH_REF", os.environ["GITHUB_REF"])

if not os.environ.get("RH_BRANCH"):
check_release = os.environ.get("RH_IS_CHECK_RELEASE", "").lower() == "true"
if not os.environ.get("RH_BRANCH") and check_release:
if os.environ.get("GITHUB_BASE_REF"):
base_ref = os.environ.get("GITHUB_BASE_REF")
print(f"Using GITHUB_BASE_REF: ${base_ref}")
Expand Down
4 changes: 3 additions & 1 deletion jupyter_releaser/actions/generate-changelog.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@

from jupyter_releaser.changelog import get_version_entry
from jupyter_releaser.util import CHECKOUT_NAME
from jupyter_releaser.util import get_branch
from jupyter_releaser.util import run

target = os.environ.get("RH_REPOSITORY")
branch = os.environ.get("RH_BRANCH")
branch = os.environ.get("RH_BRANCH", "<default>")
ref = os.environ.get("RH_REF")
since = os.environ.get("RH_SINCE")
until = os.environ.get("RH_UNTIL")
Expand All @@ -18,6 +19,7 @@
print("convert to rst:", convert_to_rst)

run("jupyter-releaser prep-git")
branch = get_branch()
orig_dir = os.getcwd()
os.chdir(CHECKOUT_NAME)
output = get_version_entry(ref, branch, target, "current", since=since, until=until)
Expand Down
1 change: 1 addition & 0 deletions jupyter_releaser/changelog.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ def get_version_entry(
str
A formatted changelog entry with markers
"""
branch = branch or util.get_branch()
since = since or util.get_latest_tag(ref or branch, since_last_stable)

util.log(f"Getting changes to {repo} since {since} on branch {branch}...")
Expand Down
1 change: 1 addition & 0 deletions jupyter_releaser/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ def draft_changelog(

def make_changelog_pr(auth, branch, repo, title, commit_message, body, dry_run=False):
repo = repo or util.get_repo()
branch = branch or util.get_branch()

# Make a new branch with a uuid suffix
pr_branch = f"changelog-{uuid.uuid1().hex}"
Expand Down
12 changes: 2 additions & 10 deletions jupyter_releaser/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,16 +108,7 @@ def log(*outputs, **kwargs):

def get_branch():
"""Get the appropriate git branch"""
if os.environ.get("GITHUB_HEAD_REF"):
# GitHub Action PR Event
branch = os.environ["GITHUB_HEAD_REF"]
elif os.environ.get("GITHUB_REF"):
# GitHub Action Push Event
# e.g. refs/heads/feature-branch-1
branch = "/".join(os.environ["GITHUB_REF"].split("/")[2:])
else:
branch = run("git branch --show-current")
return branch
return run("git branch --show-current")


def get_default_branch():
Expand Down Expand Up @@ -267,6 +258,7 @@ def actions_output(name, value):

def get_latest_tag(source, since_last_stable=False):
"""Get the default 'since' value for a branch"""
source = source or get_branch()
tags = run(f"git --no-pager tag --sort=-creatordate --merged {source}", quiet=True)
if not tags:
return ""
Expand Down

0 comments on commit ea0e6d7

Please sign in to comment.