diff --git a/.forgejo/workflows/ci.yaml b/.forgejo/workflows/ci.yaml index 0f39550..ec1a47a 100644 --- a/.forgejo/workflows/ci.yaml +++ b/.forgejo/workflows/ci.yaml @@ -185,13 +185,38 @@ jobs: - name: Release notes if: github.ref_type == 'tag' run: | - # The newest block's description, as plain text. + # The newest block's description as Markdown, for the + # release page. AppStream has no headings, so a paragraph that + # introduces a list is one:

New

comes out as + # "## New" over its items, the shape the notes take since 3.0.0. + # A paragraph on its own stays a paragraph, as the older entries + # are written. and get their Markdown spelling; a code + # span also keeps text such as lib//eh from being read as + # an HTML tag by the forge. python3 - > release-notes.md <<'EOF' - import re, html - text = open("packaging/flatpak/net.catcrafts.CrafterBuild.metainfo.xml").read() - block = re.search(r"]*>(.*?)", text, re.S).group(1) - paras = re.findall(r"

(.*?)

", block, re.S) - print("\n\n".join(html.unescape(" ".join(p.split())) for p in paras)) + import xml.etree.ElementTree as ET + + desc = ET.parse("packaging/flatpak/net.catcrafts.CrafterBuild.metainfo.xml").getroot().find("releases/release/description") + + def text(el): + parts = [el.text or ""] + for child in el: + inner = text(child) + parts.append({"em": f"*{inner}*", "code": f"`{inner}`"}.get(child.tag, inner)) + parts.append(child.tail or "") + return " ".join("".join(parts).split()) + + blocks = list(desc) + out = [] + for i, el in enumerate(blocks): + heads_list = i + 1 < len(blocks) and blocks[i + 1].tag in ("ul", "ol") + if el.tag == "p": + out.append(f"## {text(el)}" if heads_list else text(el)) + elif el.tag == "ul": + out.append("\n".join(f"- {text(li)}" for li in el)) + elif el.tag == "ol": + out.append("\n".join(f"{n}. {text(li)}" for n, li in enumerate(el, 1))) + print("\n\n".join(out)) print("\nInstall:\n\n flatpak remote-add --if-not-exists catcrafts https://flatpak.catcrafts.net/catcrafts.flatpakrepo\n flatpak install catcrafts net.catcrafts.CrafterBuild\n") EOF - name: Publish release