Skip to content

Commit db5ba07

Browse files
authored
Merge pull request #288 from blink1073/improve-ux
2 parents 57bb9a0 + d48ff8d commit db5ba07

File tree

10 files changed

+121
-82
lines changed

10 files changed

+121
-82
lines changed

.github/workflows/draft-changelog.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ on:
1414
description: Use PRs with activity since this date or git reference
1515
since_last_stable:
1616
description: Use PRs with activity since the last stable git tag
17+
type: boolean
1718
jobs:
1819
draft_changelog:
1920
runs-on: ubuntu-latest

.github/workflows/draft-release.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ on:
1616
description: Use PRs with activity since this date or git reference
1717
since_last_stable:
1818
description: Use PRs with activity since the last stable git tag
19+
type: boolean
1920
steps_to_skip:
2021
description: Comma separated list of steps to skip
2122
jobs:

.github/workflows/full-release.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ on:
1616
description: Use PRs with activity since this date or git reference
1717
since_last_stable:
1818
description: Use PRs with activity since the last stable git tag
19+
type: boolean
1920
steps_to_skip:
2021
description: Comma separated list of steps to skip
2122

.github/workflows/generate-changelog.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ on:
99
description: The branch or reference name to filter pull requests by
1010
convert_to_rst:
1111
description: Whether to convert to RST
12+
type: boolean
1213
since:
1314
description: Use PRs with activity since this date or git reference
1415
until:
Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
from jupyter_releaser.actions.common import run_action
12
from jupyter_releaser.actions.common import setup
2-
from jupyter_releaser.util import run
33

44
setup()
5-
run("jupyter-releaser prep-git")
6-
run("jupyter-releaser check-links --force")
5+
6+
run_action("jupyter-releaser prep-git")
7+
8+
run_action("jupyter-releaser check-links --force")

jupyter_releaser/actions/common.py

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,36 @@
11
import os
2+
from contextlib import contextmanager
3+
4+
from jupyter_releaser.util import run as _run
5+
6+
7+
@contextmanager
8+
def make_group(name):
9+
print(f"::group::{name}")
10+
yield
11+
print("::endgroup::")
212

313

414
def setup():
5-
# Set up env variables
6-
os.environ.setdefault("RH_REPOSITORY", os.environ["GITHUB_REPOSITORY"])
7-
os.environ.setdefault("RH_REF", os.environ["GITHUB_REF"])
8-
9-
check_release = os.environ.get("RH_IS_CHECK_RELEASE", "").lower() == "true"
10-
if not os.environ.get("RH_BRANCH") and check_release:
11-
if os.environ.get("GITHUB_BASE_REF"):
12-
base_ref = os.environ.get("GITHUB_BASE_REF")
13-
print(f"Using GITHUB_BASE_REF: ${base_ref}")
14-
os.environ["RH_BRANCH"] = base_ref
15-
16-
else:
17-
# e.g refs/head/foo or refs/tag/bar
18-
ref = os.environ["GITHUB_REF"]
19-
print(f"Using GITHUB_REF: {ref}")
20-
os.environ["RH_BRANCH"] = "/".join(ref.split("/")[2:])
15+
with make_group("Common Setup"):
16+
# Set up env variables
17+
os.environ.setdefault("RH_REPOSITORY", os.environ["GITHUB_REPOSITORY"])
18+
os.environ.setdefault("RH_REF", os.environ["GITHUB_REF"])
19+
20+
check_release = os.environ.get("RH_IS_CHECK_RELEASE", "").lower() == "true"
21+
if not os.environ.get("RH_BRANCH") and check_release:
22+
if os.environ.get("GITHUB_BASE_REF"):
23+
base_ref = os.environ.get("GITHUB_BASE_REF", "")
24+
print(f"Using GITHUB_BASE_REF: ${base_ref}")
25+
os.environ["RH_BRANCH"] = base_ref
26+
27+
else:
28+
# e.g refs/head/foo or refs/tag/bar
29+
ref = os.environ["GITHUB_REF"]
30+
print(f"Using GITHUB_REF: {ref}")
31+
os.environ["RH_BRANCH"] = "/".join(ref.split("/")[2:])
32+
33+
34+
def run_action(target, *args, **kwargs):
35+
with make_group(target):
36+
_run(target, *args, **kwargs)

jupyter_releaser/actions/draft_changelog.py

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,32 @@
22
# Distributed under the terms of the Modified BSD License.
33
import os
44

5+
from jupyter_releaser.actions.common import make_group
6+
from jupyter_releaser.actions.common import run_action
57
from jupyter_releaser.actions.common import setup
68
from jupyter_releaser.util import CHECKOUT_NAME
79
from jupyter_releaser.util import get_latest_tag
810
from jupyter_releaser.util import log
9-
from jupyter_releaser.util import run
1011

1112
setup()
12-
run("jupyter-releaser prep-git")
13+
14+
run_action("jupyter-releaser prep-git")
15+
1316

1417
# Capture the "since" argument in case we add tags befor checking changelog
1518
# Do this before bumping the version
16-
if not os.environ.get("RH_SINCE"):
17-
curr_dir = os.getcwd()
18-
os.chdir(CHECKOUT_NAME)
19-
since_last_stable = os.environ.get("RH_SINCE_LAST_STABLE")
20-
since = get_latest_tag(os.environ.get("RH_BRANCH"), since_last_stable)
21-
if since:
22-
log(f"Capturing {since} in RH_SINCE variable")
23-
os.environ["RH_SINCE"] = since
24-
os.chdir(curr_dir)
19+
with make_group("Handle RH_SINCE"):
20+
if not os.environ.get("RH_SINCE"):
21+
curr_dir = os.getcwd()
22+
os.chdir(CHECKOUT_NAME)
23+
since_last_stable = os.environ.get("RH_SINCE_LAST_STABLE")
24+
since_last_stable = since_last_stable == "true"
25+
since = get_latest_tag(os.environ.get("RH_BRANCH"), since_last_stable)
26+
if since:
27+
log(f"Capturing {since} in RH_SINCE variable")
28+
os.environ["RH_SINCE"] = since
29+
os.chdir(curr_dir)
2530

26-
run("jupyter-releaser bump-version")
27-
run("jupyter-releaser build-changelog")
28-
run("jupyter-releaser draft-changelog")
31+
run_action("jupyter-releaser bump-version")
32+
run_action("jupyter-releaser build-changelog")
33+
run_action("jupyter-releaser draft-changelog")

jupyter_releaser/actions/draft_release.py

Lines changed: 54 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
from pathlib import Path
66
from subprocess import CalledProcessError
77

8+
from jupyter_releaser.actions.common import make_group
9+
from jupyter_releaser.actions.common import run_action
810
from jupyter_releaser.actions.common import setup
911
from jupyter_releaser.changelog import extract_current
1012
from jupyter_releaser.util import CHECKOUT_NAME
@@ -14,62 +16,72 @@
1416

1517
setup()
1618

17-
check_release = os.environ.get("RH_IS_CHECK_RELEASE", "").lower() == "true"
19+
changelog_location = ""
20+
changelog_text = ""
1821

19-
if check_release:
20-
log("Handling Check Release action")
22+
with make_group("Handle Check Release"):
23+
check_release = os.environ.get("RH_IS_CHECK_RELEASE", "").lower() == "true"
2124

22-
# Extract the changelog
23-
changelog_location = os.environ.get("RH_CHANGELOG", "CHANGELOG.md")
24-
changelog_location = Path(CHECKOUT_NAME) / changelog_location
25-
changelog_text = changelog_location.read_text(encoding="utf-8")
25+
if check_release:
26+
log("Handling Check Release action")
2627

27-
# Remove the checkout
28-
shutil.rmtree(CHECKOUT_NAME)
28+
# Extract the changelog
29+
changelog_location = os.environ.get("RH_CHANGELOG", "CHANGELOG.md")
30+
changelog_location = Path(CHECKOUT_NAME) / changelog_location
31+
changelog_text = changelog_location.read_text(encoding="utf-8")
2932

30-
# Re-install jupyter-releaser if it was overshadowed
31-
try:
32-
run("jupyter-releaser --help", quiet=True, quiet_error=True)
33-
except CalledProcessError:
34-
run("pip install -q -e .")
33+
# Remove the checkout
34+
shutil.rmtree(CHECKOUT_NAME)
3535

36-
run("jupyter-releaser prep-git")
36+
# Re-install jupyter-releaser if it was overshadowed
37+
try:
38+
run("jupyter-releaser --help", quiet=True, quiet_error=True)
39+
except CalledProcessError:
40+
run("pip install -q -e .")
3741

38-
# Capture the "since" argument in case we add tags befor checking changelog
39-
# Do this before bumping the version
40-
if not os.environ.get("RH_SINCE"):
41-
curr_dir = os.getcwd()
42-
os.chdir(CHECKOUT_NAME)
43-
since_last_stable = os.environ.get("RH_SINCE_LAST_STABLE")
44-
since = get_latest_tag(os.environ.get("RH_BRANCH"), since_last_stable)
45-
if since:
46-
log(f"Capturing {since} in RH_SINCE variable")
47-
os.environ["RH_SINCE"] = since
48-
os.chdir(curr_dir)
4942

50-
run("jupyter-releaser bump-version")
43+
run_action("jupyter-releaser prep-git")
5144

52-
if check_release:
53-
# Override the changelog
54-
log("Patching the changelog")
55-
Path(changelog_location).write_text(changelog_text)
56-
log(extract_current(changelog_location))
5745

58-
run("jupyter-releaser check-changelog")
46+
with make_group("Handle RH_SINCE"):
47+
# Capture the "since" argument in case we add tags befor checking changelog
48+
# Do this before bumping the version
49+
if not os.environ.get("RH_SINCE"):
50+
curr_dir = os.getcwd()
51+
os.chdir(CHECKOUT_NAME)
52+
since_last_stable = os.environ.get("RH_SINCE_LAST_STABLE")
53+
since_last_stable = since_last_stable == "true"
54+
since = get_latest_tag(os.environ.get("RH_BRANCH"), since_last_stable)
55+
if since:
56+
log(f"Capturing {since} in RH_SINCE variable")
57+
os.environ["RH_SINCE"] = since
58+
os.chdir(curr_dir)
59+
60+
61+
run_action("jupyter-releaser bump-version")
62+
63+
with make_group("Handle Check Release"):
64+
if check_release:
65+
# Override the changelog
66+
log("Patching the changelog")
67+
Path(changelog_location).write_text(changelog_text)
68+
log(extract_current(changelog_location))
69+
70+
run_action("jupyter-releaser check-changelog")
5971

6072
# Make sure npm comes before python in case it produces
6173
# files for the python package
62-
run("jupyter-releaser build-npm")
63-
run("jupyter-releaser check-npm")
64-
run("jupyter-releaser build-python")
65-
run("jupyter-releaser check-python")
66-
run("jupyter-releaser check-manifest")
67-
run("jupyter-releaser check-links")
68-
run("jupyter-releaser tag-release")
74+
run_action("jupyter-releaser build-npm")
75+
run_action("jupyter-releaser check-npm")
76+
run_action("jupyter-releaser build-python")
77+
run_action("jupyter-releaser check-python")
78+
run_action("jupyter-releaser check-manifest")
79+
run_action("jupyter-releaser check-links")
80+
run_action("jupyter-releaser tag-release")
6981

7082
# Run check changelog again to make sure no new PRs have been merged
7183
# Skip if this is a check_release job
7284
if not check_release:
73-
run("jupyter-releaser check-changelog")
85+
run_action("jupyter-releaser check-changelog")
7486

75-
run("jupyter-releaser draft-release")
87+
run_action("jupyter-releaser draft-release")

jupyter_releaser/actions/generate-changelog.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import os
22
from pathlib import Path
33

4+
from jupyter_releaser.actions.common import run_action
45
from jupyter_releaser.changelog import get_version_entry
56
from jupyter_releaser.util import CHECKOUT_NAME
67
from jupyter_releaser.util import get_branch
7-
from jupyter_releaser.util import run
88

99
target = os.environ.get("RH_REPOSITORY")
1010
branch = os.environ.get("RH_BRANCH", "<default>")
@@ -18,7 +18,7 @@
1818
print("branch:", branch)
1919
print("convert to rst:", convert_to_rst)
2020

21-
run("jupyter-releaser prep-git")
21+
run_action("jupyter-releaser prep-git")
2222
branch = get_branch()
2323
orig_dir = os.getcwd()
2424
os.chdir(CHECKOUT_NAME)

jupyter_releaser/actions/publish_release.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
# Distributed under the terms of the Modified BSD License.
33
import os
44

5-
from jupyter_releaser.util import run
5+
from jupyter_releaser.actions.common import run_action
66

77
release_url = os.environ["release_url"]
88

99
if release_url:
10-
run(f"jupyter-releaser extract-release {release_url}")
10+
run_action(f"jupyter-releaser extract-release {release_url}")
1111

12-
run(f"jupyter-releaser publish-assets {release_url}")
12+
run_action(f"jupyter-releaser publish-assets {release_url}")
1313

1414
if release_url:
15-
run(f"jupyter-releaser forwardport-changelog {release_url}")
16-
run(f"jupyter-releaser publish-release {release_url}")
15+
run_action(f"jupyter-releaser forwardport-changelog {release_url}")
16+
run_action(f"jupyter-releaser publish-release {release_url}")

0 commit comments

Comments
 (0)