Skip to content

Commit

Permalink
Merge pull request #20 from jtpio/since
Browse files Browse the repository at this point in the history
Add Support for Since Parameter
  • Loading branch information
blink1073 committed May 12, 2021
2 parents f7f8968 + eca4958 commit 8d63818
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 14 deletions.
4 changes: 4 additions & 0 deletions .github/actions/draft-changelog/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ inputs:
description: "If set, do not make a PR"
default: "false"
required: false
since:
description: Use PRs with activity since this date or git reference
required: false
outputs:
pr_url:
description: "The URL of the Changelog Pull Request"
Expand All @@ -43,6 +46,7 @@ runs:
export RH_CHANGELOG=${{ inputs.changelog }}
export RH_DRY_RUN=${{ inputs.dry_run }}
export RH_REF=${GITHUB_REF}
export RH_SINCE=${{ inputs.since }}
# Install Jupyter Releaser from git
pip install -q git+https://github.com/jupyter-server/jupyter_releaser.git@v1
Expand Down
4 changes: 4 additions & 0 deletions .github/actions/draft-release/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ inputs:
description: "If set, do not push permanent changes"
default: "false"
required: false
since:
description: Use PRs with activity since this date or git reference
required: false
outputs:
release_url:
description: "The html URL of the draft GitHub release"
Expand All @@ -47,6 +50,7 @@ runs:
export RH_CHANGELOG=${{ inputs.changelog }}
export RH_POST_VERSION_SPEC=${{ inputs.post_version_spec }}
export RH_DRY_RUN=${{ inputs.dry_run }}
export RH_SINCE=${{ inputs.since }}
# Install Jupyter Releaser from git
pip install -q git+https://github.com/jupyter-server/jupyter_releaser.git@v1
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/draft-changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ on:
version_spec:
description: "New Version Spec"
required: true
since:
description: Use PRs with activity since this date or git reference
required: false
jobs:
changelog:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -41,6 +44,7 @@ jobs:
version_spec: ${{ github.event.inputs.version_spec }}
target: ${{ github.event.inputs.target }}
branch: ${{ github.event.inputs.branch }}
since: ${{ github.event.inputs.since }}
- name: "** Next Step **"
run: |
echo "Review PR: ${{ steps.draft-changelog.outputs.pr_url }}"
4 changes: 4 additions & 0 deletions .github/workflows/draft-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ on:
post_version_spec:
description: "Post Version Specifier"
required: false
since:
description: Use PRs with activity since this date or git reference
required: false
jobs:
release:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -48,6 +51,7 @@ jobs:
branch: ${{ github.event.inputs.branch }}
version_spec: ${{ github.event.inputs.version_spec }}
post_version_spec: ${{ github.event.inputs.post_version_spec }}
since: ${{ github.event.inputs.since }}
- name: "** Next Step **"
run: |
echo "Run the "Publish Release" Workflow with Release Url:"
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ When ready to make a release:

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

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

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.
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.
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.

<p align="center">
Expand Down
14 changes: 10 additions & 4 deletions jupyter_releaser/changelog.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ def format_pr_entry(target, number, auth=None):
return f"- {title} [#{number}]({url}) ([@{user_name}]({user_url}))"


def get_version_entry(branch, repo, version, *, auth=None, resolve_backports=False):
def get_version_entry(
branch, repo, version, *, since=None, auth=None, resolve_backports=False
):
"""Get a changelog for the changes since the last tag on the given branch.
Parameters
Expand All @@ -51,6 +53,8 @@ def get_version_entry(branch, repo, version, *, auth=None, resolve_backports=Fal
The GitHub owner/repo
version : str
The new version
since: str
Use PRs with activity since this date or git reference
auth : str, optional
The GitHub authorization token
resolve_backports: bool, optional
Expand All @@ -65,7 +69,7 @@ def get_version_entry(branch, repo, version, *, auth=None, resolve_backports=Fal
if not tags: # pragma: no cover
raise ValueError(f"No tags found on branch {branch}")

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

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


def build_entry(branch, repo, auth, changelog_path, resolve_backports):
def build_entry(branch, repo, auth, changelog_path, since, resolve_backports):
"""Build a python version entry"""
branch = branch or util.get_branch()
repo = repo or util.get_repo()
Expand All @@ -142,6 +146,7 @@ def build_entry(branch, repo, auth, changelog_path, resolve_backports):
f"origin/{branch}",
repo,
version,
since=since,
auth=auth,
resolve_backports=resolve_backports,
)
Expand Down Expand Up @@ -186,7 +191,7 @@ def format(changelog):
return re.sub(r"\n\n+$", r"\n", changelog)


def check_entry(branch, repo, auth, changelog_path, resolve_backports, output):
def check_entry(branch, repo, auth, changelog_path, since, resolve_backports, output):
"""Check changelog entry"""
branch = branch or util.get_branch()

Expand All @@ -213,6 +218,7 @@ def check_entry(branch, repo, auth, changelog_path, resolve_backports, output):
f"origin/{branch}",
repo,
version,
since=since,
auth=auth,
resolve_backports=resolve_backports,
)
Expand Down
27 changes: 21 additions & 6 deletions jupyter_releaser/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,20 @@ def main():
),
]

since_options = [
click.option(
"--since",
envvar="RH_SINCE",
default=None,
help="Use PRs with activity since this date or git reference",
)
]

changelog_options = (
branch_options
+ auth_options
+ changelog_path_options
+ since_options
+ [
click.option(
"--resolve-backports",
Expand Down Expand Up @@ -235,20 +245,21 @@ def bump_version(version_spec, version_cmd):
@main.command()
@add_options(changelog_options)
@use_checkout_dir()
def build_changelog(ref, branch, repo, auth, changelog_path, resolve_backports):
def build_changelog(ref, branch, repo, auth, changelog_path, since, resolve_backports):
"""Build changelog entry"""
changelog.build_entry(branch, repo, auth, changelog_path, resolve_backports)
changelog.build_entry(branch, repo, auth, changelog_path, since, resolve_backports)


@main.command()
@add_options(version_spec_options)
@add_options(branch_options)
@add_options(since_options)
@add_options(auth_options)
@add_options(dry_run_options)
@use_checkout_dir()
def draft_changelog(version_spec, ref, branch, repo, auth, dry_run):
def draft_changelog(version_spec, ref, branch, repo, since, auth, dry_run):
"""Create a changelog entry PR"""
lib.draft_changelog(version_spec, branch, repo, auth, dry_run)
lib.draft_changelog(version_spec, branch, repo, since, auth, dry_run)


@main.command()
Expand All @@ -257,9 +268,13 @@ def draft_changelog(version_spec, ref, branch, repo, auth, dry_run):
"--output", envvar="RH_CHANGELOG_OUTPUT", help="The output file for changelog entry"
)
@use_checkout_dir()
def check_changelog(ref, branch, repo, auth, changelog_path, resolve_backports, output):
def check_changelog(
ref, branch, repo, auth, changelog_path, since, resolve_backports, output
):
"""Check changelog entry"""
changelog.check_entry(branch, repo, auth, changelog_path, resolve_backports, output)
changelog.check_entry(
branch, repo, auth, changelog_path, since, resolve_backports, output
)


@main.command()
Expand Down
6 changes: 4 additions & 2 deletions jupyter_releaser/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def check_links(ignore_glob, ignore_links, cache_file, links_expire):
util.run(file_cmd + " --lf")


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

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

make_changelog_pr(auth, branch, repo, title, commit_message, body, dry_run=dry_run)
Expand Down
1 change: 1 addition & 0 deletions jupyter_releaser/tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ def test_list_envvars(runner):
ref: RH_REF
repo: RH_REPOSITORY
resolve-backports: RH_RESOLVE_BACKPORTS
since: RH_SINCE
test-cmd: RH_NPM_TEST_COMMAND
twine-cmd: TWINE_COMMAND
username: GITHUB_ACTOR
Expand Down

0 comments on commit 8d63818

Please sign in to comment.