Skip to content

Commit

Permalink
Add since_last_stable support in generate changelog (#482)
Browse files Browse the repository at this point in the history
  • Loading branch information
blink1073 authored Dec 22, 2022
1 parent 883e072 commit 2072877
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 13 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/generate-changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ on:
until:
description: "Use PRs with activity until this date or git reference"
required: false
since_last_stable:
description: "Use PRs with activity since the last stable git tag"
required: false
type: boolean
jobs:
generate_changelog:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -45,7 +49,8 @@ jobs:
export RH_REPOSITORY=${{ github.event.inputs.target }}
export RH_UNTIL=${{ github.event.inputs.until }}
export RH_CONVERT_TO_RST=${{ github.event.inputs.convert_to_rst }}
python -m jupyter_releaser.actions.generate-changelog
export RH_SINCE_LAST_STABLE=${{ github.event.inputs.since_last_stable }}
python -m jupyter_releaser.actions.generate_changelog
cat CHANGELOG_ENTRY.md
- uses: actions/upload-artifact@v3
Expand Down
19 changes: 11 additions & 8 deletions jupyter_releaser/actions/generate_changelog.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,22 @@

from jupyter_releaser.actions.common import run_action
from jupyter_releaser.changelog import get_version_entry
from jupyter_releaser.util import CHECKOUT_NAME, get_branch
from jupyter_releaser.util import CHECKOUT_NAME, get_branch, handle_since, log

target = os.environ.get("RH_REPOSITORY")
branch = os.environ.get("RH_BRANCH", "<default>")
ref = os.environ.get("RH_REF")
since = os.environ.get("RH_SINCE")
since = handle_since()
until = os.environ.get("RH_UNTIL")
convert_to_rst = os.environ.get("RH_CONVERT_TO_RST", "")

print("Generating changelog")
print("target:", target)
print("branch:", branch)
print("convert to rst:", convert_to_rst)
log("Generating changelog")
log("target:", target)
log("branch:", branch)
log("ref:", ref)
log("since:", since)
log("until:", until)
log("convert to rst:", convert_to_rst.lower() == "true")

run_action("jupyter-releaser prep-git")
branch = get_branch()
Expand All @@ -27,7 +30,7 @@
from pypandoc import convert_text

output = convert_text(output, "rst", "markdown")
print("\n\n------------------------------")
print(output, "------------------------------\n\n")
log("\n\n------------------------------")
log(output, "------------------------------\n\n")
os.chdir(orig_dir)
Path("CHANGELOG_ENTRY.md").write_text(output, encoding="utf-8")
9 changes: 5 additions & 4 deletions jupyter_releaser/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -632,11 +632,12 @@ def prepare_environment(fetch_draft_release=True):
return release_url


def handle_since():
def handle_since() -> str:
"""Capture the "since" argument in case we add tags before checking changelog."""
if os.environ.get("RH_SINCE"):
log(f"Using RH_SINCE from env: {os.environ.get('RH_SINCE')}")
return
since = os.environ.get("RH_SINCE", "")
if since:
log(f"Using RH_SINCE from env: {since}")
return since
curr_dir = os.getcwd()
os.chdir(CHECKOUT_NAME)
since_last_stable_env = os.environ.get("RH_SINCE_LAST_STABLE", "")
Expand Down

0 comments on commit 2072877

Please sign in to comment.