diff options
author | Jade Lovelace <lix@jade.fyi> | 2024-06-15 17:35:05 -0700 |
---|---|---|
committer | Jade Lovelace <lix@jade.fyi> | 2024-06-15 18:46:18 -0700 |
commit | 79404f7ffc99a331e89a719af009dc62d6283783 (patch) | |
tree | 8f268ef534cb2fc4dc5810496a9e04040c78b524 /releng | |
parent | f95a47e8c48a8b6eccc349d64aa5191a3618d7f4 (diff) |
releng: automatically add to the summary page
Also delete the obsolescent maintainers/release-notes script that is
unmaintained.
Change-Id: I3f4a75d790e8e00e970358ca8f32e8295c91aac3
Diffstat (limited to 'releng')
-rw-r--r-- | releng/__init__.py | 2 | ||||
-rw-r--r-- | releng/create_release.xsh | 52 | ||||
-rw-r--r-- | releng/release_notes.py | 81 |
3 files changed, 88 insertions, 47 deletions
diff --git a/releng/__init__.py b/releng/__init__.py index 179ea3e2b..65f8476af 100644 --- a/releng/__init__.py +++ b/releng/__init__.py @@ -15,6 +15,7 @@ from . import version from . import cli from . import docker from . import docker_assemble +from . import release_notes from . import gitutils @@ -77,3 +78,4 @@ def reload(): importlib.reload(docker) importlib.reload(docker_assemble) importlib.reload(gitutils) + importlib.reload(release_notes) diff --git a/releng/create_release.xsh b/releng/create_release.xsh index 242286f6c..874f71a77 100644 --- a/releng/create_release.xsh +++ b/releng/create_release.xsh @@ -6,12 +6,14 @@ from pathlib import Path import tempfile import hashlib import datetime + from . import environment from .environment import RelengEnvironment from . import keys from . import docker from .version import VERSION, RELEASE_NAME, MAJOR from .gitutils import verify_are_on_tag, git_preconditions +from . import release_notes $RAISE_SUBPROC_ERROR = True $XONSH_SHOW_TRACEBACK = True @@ -169,51 +171,7 @@ def make_artifacts_dir(eval_result, d: Path): def prepare_release_notes(): - print('[+] Preparing release notes') - RELEASE_NOTES_PATH = Path('doc/manual/rl-next') - - if RELEASE_NOTES_PATH.is_dir(): - notes_body = subprocess.check_output(['build-release-notes', '--change-authors', 'doc/manual/change-authors.yml', 'doc/manual/rl-next']).decode() - else: - # I guess nobody put release notes on their changes? - print('[-] Warning: seemingly missing any release notes, not worrying about it') - notes_body = '' - - rl_path = Path(f'doc/manual/src/release-notes/rl-{MAJOR}.md') - - existing_rl = '' - try: - with open(rl_path, 'r') as fh: - existing_rl = fh.read() - except FileNotFoundError: - pass - - date = datetime.datetime.now().strftime('%Y-%m-%d') - - minor_header = f'# Lix {VERSION} ({date})' - - header = f'# Lix {MAJOR} "{RELEASE_NAME}"' - if existing_rl.startswith(header): - # strip the header off for minor releases - lines = existing_rl.splitlines() - header = lines[0] - existing_rl = '\n'.join(lines[1:]) - else: - header += f' ({date})\n\n' - - header += '\n' + minor_header + '\n' - - notes = header - notes += notes_body - notes += "\n\n" - notes += existing_rl - - # make pre-commit happy about one newline - notes = notes.rstrip() - notes += "\n" - - with open(rl_path, 'w') as fh: - fh.write(notes) + rl_path = release_notes.build_release_notes_to_file() commit_msg = textwrap.dedent("""\ release: release notes for {VERSION} @@ -221,8 +179,8 @@ def prepare_release_notes(): {RELENG_MSG} """).format(VERSION=VERSION, RELENG_MSG=RELENG_MSG) - git add @(rl_path) - git rm doc/manual/rl-next/*.md + git add @(rl_path) @(release_notes.SUMMARY) + git rm --ignore-unmatch 'doc/manual/rl-next/*.md' git commit -m @(commit_msg) diff --git a/releng/release_notes.py b/releng/release_notes.py new file mode 100644 index 000000000..0861e8d4e --- /dev/null +++ b/releng/release_notes.py @@ -0,0 +1,81 @@ +from pathlib import Path +import subprocess +import datetime + +from .version import MAJOR, VERSION, RELEASE_NAME + +MANUAL = Path('doc/manual') +RELEASE_NOTES_BASE = MANUAL / 'src/release-notes' +VERSION_RL = RELEASE_NOTES_BASE / f'rl-{MAJOR}.md' +SUMMARY = MANUAL / 'src/SUMMARY.md' + +def add_to_summary(date: str): + # N.B: This kind of duplicates gitutils.is_maintenance_branch, but it's a more clear + # check that allows potentially releasing a -rc without release notes being + # moved, then in .0 actually move the release notes in place. + if VERSION_RL.exists(): + return + + MARKER = '<!-- RELENG-AUTO-INSERTION-MARKER' + + new_lines = [] + for line in SUMMARY.read_text().splitlines(): + new_lines.append(line) + if MARKER in line: + indent, _, _ = line.partition(MARKER) + new_lines.append(f'{indent}- [Lix {MAJOR} ({date})](release-notes/rl-{MAJOR}.md)') + + # make pre-commit happy about one newline + text = '\n'.join(new_lines).rstrip() + text += '\n' + SUMMARY.write_text(text) + +def build_release_notes_to_file(): + date = datetime.datetime.now().strftime('%Y-%m-%d') + add_to_summary(date) + + print('[+] Preparing release notes') + RELEASE_NOTES_PATH = Path('doc/manual/rl-next') + + if RELEASE_NOTES_PATH.is_dir(): + notes_body = subprocess.check_output(['build-release-notes', '--change-authors', 'doc/manual/change-authors.yml', RELEASE_NOTES_PATH]).decode() + else: + # I guess nobody put release notes on their changes? + print('[-] Warning: seemingly missing any release notes, not worrying about it') + notes_body = '' + + rl_path = Path(RELEASE_NOTES_BASE / f'rl-{MAJOR}.md') + + existing_rl = '' + try: + with open(rl_path, 'r') as fh: + existing_rl = fh.read() + except FileNotFoundError: + pass + + minor_header = f'# Lix {VERSION} ({date})' + + header = f'# Lix {MAJOR} "{RELEASE_NAME}"' + if existing_rl.startswith(header): + # strip the header off for minor releases + lines = existing_rl.splitlines() + header = lines[0] + existing_rl = '\n'.join(lines[1:]) + else: + header += f' ({date})\n\n' + + header += '\n' + minor_header + '\n' + + notes = header + notes += notes_body + notes += "\n\n" + notes += existing_rl + + # make pre-commit happy about one newline + notes = notes.rstrip() + notes += "\n" + + with open(rl_path, 'w') as fh: + fh.write(notes) + + return rl_path |