Registry changelogs as plain text

The registry shows a version's changelog as one paragraph, without Markdown
or line breaks: a shared script turns the CHANGELOG.md section into
'Added: ...; ... Fixed: ...' for both the publish and the update workflows.
This commit is contained in:
Edouard Durand
2026-09-26 08:34:19 +00:00
parent c94b90133a
commit 78415ebf25
3 changed files with 84 additions and 21 deletions
+74
View File
@@ -0,0 +1,74 @@
"""Print a version's CHANGELOG.md section as plain text for the Comfy Registry.
The registry shows a version's changelog as one paragraph: line breaks and
Markdown are not rendered. So headings become "Added:", "Fixed:"..., list
items are joined with "; ", and Markdown markup is dropped.
python .github/scripts/registry_changelog.py 1.2.2
python .github/scripts/registry_changelog.py --all # JSON {version: text}
"""
import json
import re
import sys
def sections(path="CHANGELOG.md"):
out, current = {}, None
for line in open(path, encoding="utf-8").read().splitlines():
m = re.match(r"^## (\d+\.\d+\.\d+)\b", line)
if m:
current = m.group(1)
out[current] = []
elif line.startswith("## "):
current = None
elif current:
out[current].append(line)
return out
def plain(text):
text = re.sub(r"\[([^\]]+)\]\([^)]+\)", r"\1", text) # links: keep the text
text = re.sub(r"\*\*([^*]+)\*\*", r"\1", text)
text = re.sub(r"(?<!\w)\*([^*]+)\*(?!\w)", r"\1", text)
return text.replace("`", "").strip()
def registry_text(lines):
parts, heading, items, intro = [], None, [], []
def flush():
if items:
body = "; ".join(i.rstrip(".") for i in items) + "."
parts.append(f"{heading}: {body}" if heading else body)
for raw in lines:
line = raw.strip()
if not line:
continue
if line.startswith("### "):
flush()
heading, items = plain(line[4:]), []
elif line.startswith("- "):
items.append(plain(line[2:]))
elif items:
items[-1] += " " + plain(line) # a wrapped list item
else:
intro.append(plain(line))
flush()
return " ".join(intro + parts).strip()
def main():
sys.stdout.reconfigure(encoding="utf-8")
all_sections = sections()
if sys.argv[1:] == ["--all"]:
print(json.dumps({v: registry_text(lines) for v, lines in all_sections.items()}, ensure_ascii=False))
elif len(sys.argv) == 2:
print(registry_text(all_sections.get(sys.argv[1], [])))
else:
sys.exit(__doc__)
if __name__ == "__main__":
main()
+6 -10
View File
@@ -15,15 +15,11 @@ jobs:
- name: Check out code
uses: actions/checkout@v7
- name: Changelog for this version
# comfy-cli sends COMFY_NODE_CHANGELOG as the version's changelog
# (the registry's Updates section): the matching CHANGELOG.md section.
# comfy-cli sends COMFY_NODE_CHANGELOG as the version's changelog (the
# registry's Updates section), as plain text: the registry shows one paragraph.
run: |
version=$(sed -n 's/^version = "\(.*\)"/\1/p' pyproject.toml | head -n1)
notes=$(awk -v v="$version" '
$0 ~ "^## " v "( |$)" { on = 1; next }
on && /^## / { exit }
on { print }
' CHANGELOG.md | sed -e '/./,$!d')
notes=$(python3 .github/scripts/registry_changelog.py "$version")
if [ -z "$notes" ]; then
echo "::warning::No CHANGELOG.md section for $version"
exit 0
@@ -31,11 +27,11 @@ jobs:
delimiter="EOF_$(date +%s%N)"
{
echo "COMFY_NODE_CHANGELOG<<$delimiter"
printf '%s\n' "$notes"
printf '%s
' "$notes"
echo "$delimiter"
} >> "$GITHUB_ENV"
echo "Changelog for $version:"
printf '%s\n' "$notes"
echo "Changelog for $version: $notes"
- name: Publish Custom Node
uses: Comfy-Org/publish-node-action@main
with:
+4 -11
View File
@@ -28,17 +28,10 @@ jobs:
publisher = re.search(r'^PublisherId\s*=\s*"([^"]+)"', open("pyproject.toml").read(), re.M).group(1)
node = re.search(r'^name\s*=\s*"([^"]+)"', open("pyproject.toml").read(), re.M).group(1)
sections, current = {}, None
for line in open("CHANGELOG.md", encoding="utf-8").read().splitlines():
m = re.match(r"^## (\d+\.\d+\.\d+)\b", line)
if m:
current = m.group(1)
sections[current] = []
elif line.startswith("## "):
current = None
elif current:
sections[current].append(line)
notes = {v: "\n".join(lines).strip() for v, lines in sections.items()}
import subprocess
# Plain text: the registry shows the changelog as one paragraph.
notes = json.loads(subprocess.check_output(
[sys.executable, ".github/scripts/registry_changelog.py", "--all"], text=True, encoding="utf-8"))
with urllib.request.urlopen(f"{API}/nodes/{node}/versions") as r:
published = json.load(r)