diff --git a/.github/actions/draft-changelog/action.yml b/.github/actions/draft-changelog/action.yml index 0e2443fe..762ae852 100644 --- a/.github/actions/draft-changelog/action.yml +++ b/.github/actions/draft-changelog/action.yml @@ -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" @@ -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 diff --git a/.github/actions/draft-release/action.yml b/.github/actions/draft-release/action.yml index 429ee6e3..2d5e4418 100644 --- a/.github/actions/draft-release/action.yml +++ b/.github/actions/draft-release/action.yml @@ -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" @@ -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 diff --git a/.github/workflows/draft-changelog.yml b/.github/workflows/draft-changelog.yml index 651c3d89..3eb36999 100644 --- a/.github/workflows/draft-changelog.yml +++ b/.github/workflows/draft-changelog.yml @@ -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 @@ -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 }}" diff --git a/.github/workflows/draft-release.yml b/.github/workflows/draft-release.yml index f5d73c32..cee54f2e 100644 --- a/.github/workflows/draft-release.yml +++ b/.github/workflows/draft-release.yml @@ -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 @@ -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:" diff --git a/README.md b/README.md index 2610974e..93dc3933 100644 --- a/README.md +++ b/README.md @@ -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.

Draft Changelog Workflow

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

diff --git a/jupyter_releaser/changelog.py b/jupyter_releaser/changelog.py index cb338719..40ec1a30 100644 --- a/jupyter_releaser/changelog.py +++ b/jupyter_releaser/changelog.py @@ -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 @@ -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 @@ -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}...") @@ -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() @@ -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, ) @@ -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() @@ -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, ) diff --git a/jupyter_releaser/cli.py b/jupyter_releaser/cli.py index 699b7c34..b8a05551 100644 --- a/jupyter_releaser/cli.py +++ b/jupyter_releaser/cli.py @@ -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", @@ -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() @@ -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() diff --git a/jupyter_releaser/lib.py b/jupyter_releaser/lib.py index fa229e91..5ac718c5 100644 --- a/jupyter_releaser/lib.py +++ b/jupyter_releaser/lib.py @@ -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() @@ -105,7 +105,7 @@ 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 | | ------------- | ------------- | @@ -113,6 +113,8 @@ def draft_changelog(version_spec, branch, repo, auth, dry_run): | 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) diff --git a/jupyter_releaser/tests/test_cli.py b/jupyter_releaser/tests/test_cli.py index 1fbfef10..3a22f630 100644 --- a/jupyter_releaser/tests/test_cli.py +++ b/jupyter_releaser/tests/test_cli.py @@ -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