Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion scripts/sync_release_history.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@
HEADING_RE = re.compile(r"^(#{2,3})\s+(.+?)\s*$")
LINK_RE = re.compile(r"\[([^\]]+)\]\((https?://[^)]+)\)")
CODE_RE = re.compile(r"`([^`]+)`")
RST_HEADER = [
".. SPDX-FileCopyrightText: 2026 LibreCode coop and contributors",
".. SPDX-License-" + "Identifier: AGPL-3.0-or-later",
"",
]


def load_json(path: Path) -> dict[str, object]:
Expand All @@ -33,7 +38,7 @@ def markdown_section_to_rst(section: str, version: str) -> str:
if not lines:
raise ValueError("changelog section must not be empty")

output: list[str] = []
output: list[str] = [*RST_HEADER, ".. This file is generated from LibreSign/libresign release history.", ""]
first_heading_seen = False
for raw in lines:
match = HEADING_RE.match(raw)
Expand Down Expand Up @@ -85,6 +90,7 @@ def render_major_index(major: int, versions: list[str]) -> str:
ordered = sorted(versions, key=version_key, reverse=True)
title = f"LibreSign {major}"
body = [
*RST_HEADER,
".. This file is generated from LibreSign release history. Do not edit release text here manually.",
"",
title,
Expand All @@ -101,6 +107,7 @@ def render_major_index(major: int, versions: list[str]) -> str:
def render_root_index(majors: list[int]) -> str:
title = "Release history"
body = [
*RST_HEADER,
".. This file is generated. Release text is sourced from LibreSign/libresign per-major changelogs.",
"",
title,
Expand Down
2 changes: 2 additions & 0 deletions tests/test_sync_release_history.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def test_markdown_release_section_becomes_browsable_rst(self) -> None:
self.assertIn("15.1.0 - 2026-09-21", rendered)
self.assertIn("Added\n-----", rendered)
self.assertIn("`#10 <https://github.com/LibreSign/libresign/pull/10>`_", rendered)
self.assertIn("AGPL-3.0-or-later", rendered)

def test_synchronization_requires_successful_matching_publication(self) -> None:
with tempfile.TemporaryDirectory() as directory:
Expand Down Expand Up @@ -67,6 +68,7 @@ def test_synchronization_is_idempotent_and_indexes_major(self) -> None:
self.assertEqual(first, second)
self.assertIn("15.1.0", (docs / "developer_manual/release-history/15/index.rst").read_text(encoding="utf-8"))
self.assertIn("LibreSign 15 <15/index>", (docs / "developer_manual/release-history/index.rst").read_text(encoding="utf-8"))
self.assertIn("AGPL-3.0-or-later", (docs / "developer_manual/release-history/15/index.rst").read_text(encoding="utf-8"))

def test_versions_sort_semantically(self) -> None:
versions = ["15.9.0", "15.10.0", "15.10.0-rc.1", "15.2.4"]
Expand Down
Loading