|
5 | 5 | from pathlib import Path
|
6 | 6 | from subprocess import CalledProcessError
|
7 | 7 |
|
| 8 | +from jupyter_releaser.actions.common import make_group |
| 9 | +from jupyter_releaser.actions.common import run_action |
8 | 10 | from jupyter_releaser.actions.common import setup
|
9 | 11 | from jupyter_releaser.changelog import extract_current
|
10 | 12 | from jupyter_releaser.util import CHECKOUT_NAME
|
|
14 | 16 |
|
15 | 17 | setup()
|
16 | 18 |
|
17 |
| -check_release = os.environ.get("RH_IS_CHECK_RELEASE", "").lower() == "true" |
| 19 | +changelog_location = "" |
| 20 | +changelog_text = "" |
18 | 21 |
|
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" |
21 | 24 |
|
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") |
26 | 27 |
|
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") |
29 | 32 |
|
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) |
35 | 35 |
|
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 .") |
37 | 41 |
|
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) |
49 | 42 |
|
50 |
| -run("jupyter-releaser bump-version") |
| 43 | +run_action("jupyter-releaser prep-git") |
51 | 44 |
|
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)) |
57 | 45 |
|
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") |
59 | 71 |
|
60 | 72 | # Make sure npm comes before python in case it produces
|
61 | 73 | # 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") |
69 | 81 |
|
70 | 82 | # Run check changelog again to make sure no new PRs have been merged
|
71 | 83 | # Skip if this is a check_release job
|
72 | 84 | if not check_release:
|
73 |
| - run("jupyter-releaser check-changelog") |
| 85 | + run_action("jupyter-releaser check-changelog") |
74 | 86 |
|
75 |
| -run("jupyter-releaser draft-release") |
| 87 | +run_action("jupyter-releaser draft-release") |
0 commit comments