Skip to content

Commit 2072877

Browse files
authored
Add since_last_stable support in generate changelog (#482)
1 parent 883e072 commit 2072877

File tree

3 files changed

+22
-13
lines changed

3 files changed

+22
-13
lines changed

.github/workflows/generate-changelog.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ on:
1818
until:
1919
description: "Use PRs with activity until this date or git reference"
2020
required: false
21+
since_last_stable:
22+
description: "Use PRs with activity since the last stable git tag"
23+
required: false
24+
type: boolean
2125
jobs:
2226
generate_changelog:
2327
runs-on: ubuntu-latest
@@ -45,7 +49,8 @@ jobs:
4549
export RH_REPOSITORY=${{ github.event.inputs.target }}
4650
export RH_UNTIL=${{ github.event.inputs.until }}
4751
export RH_CONVERT_TO_RST=${{ github.event.inputs.convert_to_rst }}
48-
python -m jupyter_releaser.actions.generate-changelog
52+
export RH_SINCE_LAST_STABLE=${{ github.event.inputs.since_last_stable }}
53+
python -m jupyter_releaser.actions.generate_changelog
4954
cat CHANGELOG_ENTRY.md
5055
5156
- uses: actions/upload-artifact@v3

jupyter_releaser/actions/generate_changelog.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,22 @@
33

44
from jupyter_releaser.actions.common import run_action
55
from jupyter_releaser.changelog import get_version_entry
6-
from jupyter_releaser.util import CHECKOUT_NAME, get_branch
6+
from jupyter_releaser.util import CHECKOUT_NAME, get_branch, handle_since, log
77

88
target = os.environ.get("RH_REPOSITORY")
99
branch = os.environ.get("RH_BRANCH", "<default>")
1010
ref = os.environ.get("RH_REF")
11-
since = os.environ.get("RH_SINCE")
11+
since = handle_since()
1212
until = os.environ.get("RH_UNTIL")
1313
convert_to_rst = os.environ.get("RH_CONVERT_TO_RST", "")
1414

15-
print("Generating changelog")
16-
print("target:", target)
17-
print("branch:", branch)
18-
print("convert to rst:", convert_to_rst)
15+
log("Generating changelog")
16+
log("target:", target)
17+
log("branch:", branch)
18+
log("ref:", ref)
19+
log("since:", since)
20+
log("until:", until)
21+
log("convert to rst:", convert_to_rst.lower() == "true")
1922

2023
run_action("jupyter-releaser prep-git")
2124
branch = get_branch()
@@ -27,7 +30,7 @@
2730
from pypandoc import convert_text
2831

2932
output = convert_text(output, "rst", "markdown")
30-
print("\n\n------------------------------")
31-
print(output, "------------------------------\n\n")
33+
log("\n\n------------------------------")
34+
log(output, "------------------------------\n\n")
3235
os.chdir(orig_dir)
3336
Path("CHANGELOG_ENTRY.md").write_text(output, encoding="utf-8")

jupyter_releaser/util.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -632,11 +632,12 @@ def prepare_environment(fetch_draft_release=True):
632632
return release_url
633633

634634

635-
def handle_since():
635+
def handle_since() -> str:
636636
"""Capture the "since" argument in case we add tags before checking changelog."""
637-
if os.environ.get("RH_SINCE"):
638-
log(f"Using RH_SINCE from env: {os.environ.get('RH_SINCE')}")
639-
return
637+
since = os.environ.get("RH_SINCE", "")
638+
if since:
639+
log(f"Using RH_SINCE from env: {since}")
640+
return since
640641
curr_dir = os.getcwd()
641642
os.chdir(CHECKOUT_NAME)
642643
since_last_stable_env = os.environ.get("RH_SINCE_LAST_STABLE", "")

0 commit comments

Comments
 (0)