Skip to content

Commit ea0e6d7

Browse files
authored
Merge pull request #223 from blink1073/default-branch
Make branch and version spec optional
2 parents 18d0a59 + fa8749a commit ea0e6d7

File tree

10 files changed

+10
-34
lines changed

10 files changed

+10
-34
lines changed

.github/workflows/draft-changelog.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,12 @@ on:
77
required: true
88
branch:
99
description: "The branch to target"
10-
required: true
1110
version_spec:
1211
description: "New Version Spec"
13-
required: true
1412
since:
1513
description: Use PRs with activity since this date or git reference
16-
required: false
1714
since_last_stable:
1815
description: Use PRs with activity since the last stable git tag
19-
required: false
2016
jobs:
2117
draft_changelog:
2218
runs-on: ubuntu-latest

.github/workflows/draft-release.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,16 @@ on:
77
required: true
88
branch:
99
description: "The branch to target"
10-
required: true
1110
version_spec:
1211
description: "New Version Specifier"
13-
required: true
1412
post_version_spec:
1513
description: "Post Version Specifier"
16-
required: false
1714
since:
1815
description: Use PRs with activity since this date or git reference
19-
required: false
2016
since_last_stable:
2117
description: Use PRs with activity since the last stable git tag
22-
required: false
2318
steps_to_skip:
2419
description: Comma separated list of steps to skip
25-
required: false
2620
jobs:
2721
draft_release:
2822
runs-on: ubuntu-latest

.github/workflows/full-release.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,16 @@ on:
77
required: true
88
branch:
99
description: "The branch to target"
10-
required: true
1110
version_spec:
1211
description: "New Version Specifier"
13-
required: true
1412
post_version_spec:
1513
description: "Post Version Specifier"
16-
required: false
1714
since:
1815
description: Use PRs with activity since this date or git reference
19-
required: false
2016
since_last_stable:
2117
description: Use PRs with activity since the last stable git tag
22-
required: false
2318
steps_to_skip:
2419
description: Comma separated list of steps to skip
25-
required: false
2620

2721
jobs:
2822
full_release:

.github/workflows/generate-changelog.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,12 @@ on:
77
required: true
88
branch:
99
description: The branch or reference name to filter pull requests by
10-
required: true
1110
convert_to_rst:
1211
description: Whether to convert to RST
13-
required: false
1412
since:
1513
description: Use PRs with activity since this date or git reference
16-
required: false
1714
until:
1815
description: Use PRs with activity until this date or git reference
19-
required: false
2016
jobs:
2117
generate_changelog:
2218
runs-on: ubuntu-latest

.github/workflows/publish-release.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ on:
66
description: "The URL of the draft GitHub release"
77
required: true
88
steps_to_skip:
9-
description: comma-separated list of steps to steps_to_skip
10-
required: false
9+
description: comma-separated list of steps to skip
1110
jobs:
1211
publish_release:
1312
runs-on: ubuntu-latest

jupyter_releaser/actions/common.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ def setup():
66
os.environ.setdefault("RH_REPOSITORY", os.environ["GITHUB_REPOSITORY"])
77
os.environ.setdefault("RH_REF", os.environ["GITHUB_REF"])
88

9-
if not os.environ.get("RH_BRANCH"):
9+
check_release = os.environ.get("RH_IS_CHECK_RELEASE", "").lower() == "true"
10+
if not os.environ.get("RH_BRANCH") and check_release:
1011
if os.environ.get("GITHUB_BASE_REF"):
1112
base_ref = os.environ.get("GITHUB_BASE_REF")
1213
print(f"Using GITHUB_BASE_REF: ${base_ref}")

jupyter_releaser/actions/generate-changelog.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33

44
from jupyter_releaser.changelog import get_version_entry
55
from jupyter_releaser.util import CHECKOUT_NAME
6+
from jupyter_releaser.util import get_branch
67
from jupyter_releaser.util import run
78

89
target = os.environ.get("RH_REPOSITORY")
9-
branch = os.environ.get("RH_BRANCH")
10+
branch = os.environ.get("RH_BRANCH", "<default>")
1011
ref = os.environ.get("RH_REF")
1112
since = os.environ.get("RH_SINCE")
1213
until = os.environ.get("RH_UNTIL")
@@ -18,6 +19,7 @@
1819
print("convert to rst:", convert_to_rst)
1920

2021
run("jupyter-releaser prep-git")
22+
branch = get_branch()
2123
orig_dir = os.getcwd()
2224
os.chdir(CHECKOUT_NAME)
2325
output = get_version_entry(ref, branch, target, "current", since=since, until=until)

jupyter_releaser/changelog.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ def get_version_entry(
8080
str
8181
A formatted changelog entry with markers
8282
"""
83+
branch = branch or util.get_branch()
8384
since = since or util.get_latest_tag(ref or branch, since_last_stable)
8485

8586
util.log(f"Getting changes to {repo} since {since} on branch {branch}...")

jupyter_releaser/lib.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ def draft_changelog(
139139

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

143144
# Make a new branch with a uuid suffix
144145
pr_branch = f"changelog-{uuid.uuid1().hex}"

jupyter_releaser/util.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -108,16 +108,7 @@ def log(*outputs, **kwargs):
108108

109109
def get_branch():
110110
"""Get the appropriate git branch"""
111-
if os.environ.get("GITHUB_HEAD_REF"):
112-
# GitHub Action PR Event
113-
branch = os.environ["GITHUB_HEAD_REF"]
114-
elif os.environ.get("GITHUB_REF"):
115-
# GitHub Action Push Event
116-
# e.g. refs/heads/feature-branch-1
117-
branch = "/".join(os.environ["GITHUB_REF"].split("/")[2:])
118-
else:
119-
branch = run("git branch --show-current")
120-
return branch
111+
return run("git branch --show-current")
121112

122113

123114
def get_default_branch():
@@ -267,6 +258,7 @@ def actions_output(name, value):
267258

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

0 commit comments

Comments
 (0)