certbot/tools/extract_changelog.py
ohemorange bc0b54950a
Run changelog generation stage on ubuntu-latest, nightly (#10349)
Fixes https://github.com/certbot/certbot/issues/10328

This PR:
1) Moves changelog generation to ubuntu-latest instead of deprecated
windows, and
2) Sets it to run nightly so we catch breakages before release day
3) Modifies `update_changelog.py` to also allow `.dev0` version numbers
and headings with `main` instead of the date in them, for testing.

I could have been more specific about only matching `main` or a date,
but that seemed honestly unnecessary.

Here is a manually triggered nightly test; the test branch just
[removes](https://github.com/certbot/certbot/compare/changelog-gen...nightly-changelog-gen?expand=1)
all the other tests for speed:
https://dev.azure.com/certbot/certbot/_build/results?buildId=9250&view=results

You can download the created changelog artifact here:
https://dev.azure.com/certbot/certbot/_build/results?buildId=9250&view=artifacts&pathAsName=false&type=publishedArtifacts
2025-06-20 09:38:34 -07:00

41 lines
990 B
Python
Executable file

#!/usr/bin/env python
from __future__ import print_function
import os
import re
import sys
CERTBOT_ROOT = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
NEW_SECTION_PATTERN = re.compile(r'^##\s*[\d.]+\s*-\s*[\d-]+$')
def main():
version = sys.argv[1]
if version.endswith('.dev0'):
version = version[:-5]
section_pattern = re.compile(r'^##\s*{0}\s*-\s*.*$'
.format(version.replace('.', '\\.')))
with open(os.path.join(CERTBOT_ROOT, 'certbot', 'CHANGELOG.md')) as file_h:
lines = file_h.read().splitlines()
changelog = []
i = 0
while i < len(lines):
if section_pattern.match(lines[i]):
i = i + 2
while i < len(lines):
if NEW_SECTION_PATTERN.match(lines[i]):
break
changelog.append(lines[i])
i = i + 1
i = i + 1
print('\n'.join(changelog))
if __name__ == '__main__':
main()