diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3bbe7b6 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +__pycache__/ +*.pyc +*.pyo diff --git a/README.md b/README.md index 00b98ec..7f447be 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ GitHub Action to generate a `CHANGELOG.md` on new tags, with optional Telegram n ## Breaking changes in 2.x -- The action now lives at the repository root and is used as `Waveful/ChangelogAction@2`. +- The action now lives at the repository root and is used as `Waveful/ChangelogAction@v2.0.1`. - The old split actions (`/generate`, `/notify`, `/annotate`) have been removed from the default setup. - Changelog generation is always the default behavior. - Telegram notification only runs when `telegram-bot-token`, `telegram-chat-id`, and `changelog-url` are all provided. @@ -67,7 +67,7 @@ jobs: steps: - name: Run changelog action id: changelog - uses: Waveful/ChangelogAction@2 + uses: Waveful/ChangelogAction@v2.0.1 with: github-token: ${{ secrets.GITHUB_TOKEN }} target-branch: master diff --git a/action.yml b/action.yml index 1027af1..ebdf5c6 100644 --- a/action.yml +++ b/action.yml @@ -320,6 +320,8 @@ runs: github_output.write(f"entry-file={path.resolve()}\n") PY + python3 "${{ github.action_path }}/scripts/normalize_changelog.py" "$CHANGELOG_FILE" + - name: Update CHANGELOG.md shell: bash run: | @@ -354,6 +356,8 @@ runs: changelog_path.write_text(updated, encoding="utf-8") PY + + python3 "${{ github.action_path }}/scripts/normalize_changelog.py" CHANGELOG.md env: CHANGELOG_FILE: ${{ steps.changelog.outputs.entry-file }} diff --git a/scripts/normalize_changelog.py b/scripts/normalize_changelog.py new file mode 100644 index 0000000..d10fe72 --- /dev/null +++ b/scripts/normalize_changelog.py @@ -0,0 +1,37 @@ +#!/usr/bin/env python3 +"""Normalize markdown formatting in changelog text. + +Ensures bullet lines (•) render on separate lines in markdown previews +and that ## headings are properly separated from surrounding content. +""" + +import argparse +import re +from pathlib import Path + + +def normalize(text): + # Ensure blank line before ## headings (when not already preceded by one) + text = re.sub(r"(?