diff --git a/.github/scripts/registry_changelog.py b/.github/scripts/registry_changelog.py new file mode 100644 index 0000000..4b53af9 --- /dev/null +++ b/.github/scripts/registry_changelog.py @@ -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"(?> "$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: diff --git a/.github/workflows/registry-changelogs.yml b/.github/workflows/registry-changelogs.yml index fd2c1c8..4fe4da6 100644 --- a/.github/workflows/registry-changelogs.yml +++ b/.github/workflows/registry-changelogs.yml @@ -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)