Skip to content

Commit eca4958

Browse files
committed
Add Support for Since Parameter
1 parent f7f8968 commit eca4958

File tree

9 files changed

+55
-14
lines changed

9 files changed

+55
-14
lines changed

.github/actions/draft-changelog/action.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ inputs:
2121
description: "If set, do not make a PR"
2222
default: "false"
2323
required: false
24+
since:
25+
description: Use PRs with activity since this date or git reference
26+
required: false
2427
outputs:
2528
pr_url:
2629
description: "The URL of the Changelog Pull Request"
@@ -43,6 +46,7 @@ runs:
4346
export RH_CHANGELOG=${{ inputs.changelog }}
4447
export RH_DRY_RUN=${{ inputs.dry_run }}
4548
export RH_REF=${GITHUB_REF}
49+
export RH_SINCE=${{ inputs.since }}
4650
4751
# Install Jupyter Releaser from git
4852
pip install -q git+https://github.com/jupyter-server/jupyter_releaser.git@v1

.github/actions/draft-release/action.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ inputs:
2424
description: "If set, do not push permanent changes"
2525
default: "false"
2626
required: false
27+
since:
28+
description: Use PRs with activity since this date or git reference
29+
required: false
2730
outputs:
2831
release_url:
2932
description: "The html URL of the draft GitHub release"
@@ -47,6 +50,7 @@ runs:
4750
export RH_CHANGELOG=${{ inputs.changelog }}
4851
export RH_POST_VERSION_SPEC=${{ inputs.post_version_spec }}
4952
export RH_DRY_RUN=${{ inputs.dry_run }}
53+
export RH_SINCE=${{ inputs.since }}
5054
5155
# Install Jupyter Releaser from git
5256
pip install -q git+https://github.com/jupyter-server/jupyter_releaser.git@v1

.github/workflows/draft-changelog.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ on:
1111
version_spec:
1212
description: "New Version Spec"
1313
required: true
14+
since:
15+
description: Use PRs with activity since this date or git reference
16+
required: false
1417
jobs:
1518
changelog:
1619
runs-on: ubuntu-latest
@@ -41,6 +44,7 @@ jobs:
4144
version_spec: ${{ github.event.inputs.version_spec }}
4245
target: ${{ github.event.inputs.target }}
4346
branch: ${{ github.event.inputs.branch }}
47+
since: ${{ github.event.inputs.since }}
4448
- name: "** Next Step **"
4549
run: |
4650
echo "Review PR: ${{ steps.draft-changelog.outputs.pr_url }}"

.github/workflows/draft-release.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ on:
1414
post_version_spec:
1515
description: "Post Version Specifier"
1616
required: false
17+
since:
18+
description: Use PRs with activity since this date or git reference
19+
required: false
1720
jobs:
1821
release:
1922
runs-on: ubuntu-latest
@@ -48,6 +51,7 @@ jobs:
4851
branch: ${{ github.event.inputs.branch }}
4952
version_spec: ${{ github.event.inputs.version_spec }}
5053
post_version_spec: ${{ github.event.inputs.post_version_spec }}
54+
since: ${{ github.event.inputs.since }}
5155
- name: "** Next Step **"
5256
run: |
5357
echo "Run the "Publish Release" Workflow with Release Url:"

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ When ready to make a release:
3535

3636
1. Fork the `jupyter-releaser` repo and go to the Actions panel
3737
2. Select the `Draft Changelog` workflow
38-
3. Run the workflow with the version spec (usually the new version number)
38+
3. Run the workflow with the version spec (usually the new version number). If making a final release after
39+
a prerelease series, you may wish to use the "until" parameter to include all the PRs since the last final release.
3940

4041
<p align="center">
4142
<img src="media/draft_changelog_workflow.png" alt="Draft Changelog Workflow"
@@ -63,7 +64,7 @@ When ready to make a release:
6364
title="Draft Release Workflow" width="50%"/>
6465
</p>
6566

66-
8. Run the workflow with the same version spec as before, and optionally, a post version spec if you want to go back to a dev version in the target branch.
67+
8. Run the workflow with the same version spec as before, and optionally, a post version spec if you want to go back to a dev version in the target branch. Make sure to use the same "until" parameter used in "Draft Changelog", if applicable.
6768
9. When the workflow completes, go to the releases page in the target repository and verify that the new draft release is there with the correct changelog and dist files.
6869

6970
<p align="center">

jupyter_releaser/changelog.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ def format_pr_entry(target, number, auth=None):
4040
return f"- {title} [#{number}]({url}) ([@{user_name}]({user_url}))"
4141

4242

43-
def get_version_entry(branch, repo, version, *, auth=None, resolve_backports=False):
43+
def get_version_entry(
44+
branch, repo, version, *, since=None, auth=None, resolve_backports=False
45+
):
4446
"""Get a changelog for the changes since the last tag on the given branch.
4547
4648
Parameters
@@ -51,6 +53,8 @@ def get_version_entry(branch, repo, version, *, auth=None, resolve_backports=Fal
5153
The GitHub owner/repo
5254
version : str
5355
The new version
56+
since: str
57+
Use PRs with activity since this date or git reference
5458
auth : str, optional
5559
The GitHub authorization token
5660
resolve_backports: bool, optional
@@ -65,7 +69,7 @@ def get_version_entry(branch, repo, version, *, auth=None, resolve_backports=Fal
6569
if not tags: # pragma: no cover
6670
raise ValueError(f"No tags found on branch {branch}")
6771

68-
since = tags.splitlines()[0]
72+
since = since or tags.splitlines()[0]
6973
branch = branch.split("/")[-1]
7074
util.log(f"Getting changes to {repo} since {since} on branch {branch}...")
7175

@@ -120,7 +124,7 @@ def get_version_entry(branch, repo, version, *, auth=None, resolve_backports=Fal
120124
return output
121125

122126

123-
def build_entry(branch, repo, auth, changelog_path, resolve_backports):
127+
def build_entry(branch, repo, auth, changelog_path, since, resolve_backports):
124128
"""Build a python version entry"""
125129
branch = branch or util.get_branch()
126130
repo = repo or util.get_repo()
@@ -142,6 +146,7 @@ def build_entry(branch, repo, auth, changelog_path, resolve_backports):
142146
f"origin/{branch}",
143147
repo,
144148
version,
149+
since=since,
145150
auth=auth,
146151
resolve_backports=resolve_backports,
147152
)
@@ -186,7 +191,7 @@ def format(changelog):
186191
return re.sub(r"\n\n+$", r"\n", changelog)
187192

188193

189-
def check_entry(branch, repo, auth, changelog_path, resolve_backports, output):
194+
def check_entry(branch, repo, auth, changelog_path, since, resolve_backports, output):
190195
"""Check changelog entry"""
191196
branch = branch or util.get_branch()
192197

@@ -213,6 +218,7 @@ def check_entry(branch, repo, auth, changelog_path, resolve_backports, output):
213218
f"origin/{branch}",
214219
repo,
215220
version,
221+
since=since,
216222
auth=auth,
217223
resolve_backports=resolve_backports,
218224
)

jupyter_releaser/cli.py

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -170,10 +170,20 @@ def main():
170170
),
171171
]
172172

173+
since_options = [
174+
click.option(
175+
"--since",
176+
envvar="RH_SINCE",
177+
default=None,
178+
help="Use PRs with activity since this date or git reference",
179+
)
180+
]
181+
173182
changelog_options = (
174183
branch_options
175184
+ auth_options
176185
+ changelog_path_options
186+
+ since_options
177187
+ [
178188
click.option(
179189
"--resolve-backports",
@@ -235,20 +245,21 @@ def bump_version(version_spec, version_cmd):
235245
@main.command()
236246
@add_options(changelog_options)
237247
@use_checkout_dir()
238-
def build_changelog(ref, branch, repo, auth, changelog_path, resolve_backports):
248+
def build_changelog(ref, branch, repo, auth, changelog_path, since, resolve_backports):
239249
"""Build changelog entry"""
240-
changelog.build_entry(branch, repo, auth, changelog_path, resolve_backports)
250+
changelog.build_entry(branch, repo, auth, changelog_path, since, resolve_backports)
241251

242252

243253
@main.command()
244254
@add_options(version_spec_options)
245255
@add_options(branch_options)
256+
@add_options(since_options)
246257
@add_options(auth_options)
247258
@add_options(dry_run_options)
248259
@use_checkout_dir()
249-
def draft_changelog(version_spec, ref, branch, repo, auth, dry_run):
260+
def draft_changelog(version_spec, ref, branch, repo, since, auth, dry_run):
250261
"""Create a changelog entry PR"""
251-
lib.draft_changelog(version_spec, branch, repo, auth, dry_run)
262+
lib.draft_changelog(version_spec, branch, repo, since, auth, dry_run)
252263

253264

254265
@main.command()
@@ -257,9 +268,13 @@ def draft_changelog(version_spec, ref, branch, repo, auth, dry_run):
257268
"--output", envvar="RH_CHANGELOG_OUTPUT", help="The output file for changelog entry"
258269
)
259270
@use_checkout_dir()
260-
def check_changelog(ref, branch, repo, auth, changelog_path, resolve_backports, output):
271+
def check_changelog(
272+
ref, branch, repo, auth, changelog_path, since, resolve_backports, output
273+
):
261274
"""Check changelog entry"""
262-
changelog.check_entry(branch, repo, auth, changelog_path, resolve_backports, output)
275+
changelog.check_entry(
276+
branch, repo, auth, changelog_path, since, resolve_backports, output
277+
)
263278

264279

265280
@main.command()

jupyter_releaser/lib.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def check_links(ignore_glob, ignore_links, cache_file, links_expire):
8484
util.run(file_cmd + " --lf")
8585

8686

87-
def draft_changelog(version_spec, branch, repo, auth, dry_run):
87+
def draft_changelog(version_spec, branch, repo, since, auth, dry_run):
8888
"""Create a changelog entry PR"""
8989
repo = repo or util.get_repo()
9090
branch = branch or util.get_branch()
@@ -105,14 +105,16 @@ def draft_changelog(version_spec, branch, repo, auth, dry_run):
105105
if util.PACKAGE_JSON.exists():
106106
body += npm.get_package_versions(version)
107107

108-
body += '\n\nAfter merging this PR run the "Draft Release" Workflow with the following inputs'
108+
body += '\n\nAfter merging this PR run the "Draft Release" Workflow on your fork of `jupyter_releaser` with the following inputs'
109109
body += f"""
110110
| Input | Value |
111111
| ------------- | ------------- |
112112
| Target | {repo} |
113113
| Branch | {branch} |
114114
| Version Spec | {version_spec} |
115115
"""
116+
if since:
117+
body += "| Since | {since} |"
116118
util.log(body)
117119

118120
make_changelog_pr(auth, branch, repo, title, commit_message, body, dry_run=dry_run)

jupyter_releaser/tests/test_cli.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ def test_list_envvars(runner):
129129
ref: RH_REF
130130
repo: RH_REPOSITORY
131131
resolve-backports: RH_RESOLVE_BACKPORTS
132+
since: RH_SINCE
132133
test-cmd: RH_NPM_TEST_COMMAND
133134
twine-cmd: TWINE_COMMAND
134135
username: GITHUB_ACTOR

0 commit comments

Comments
 (0)