From c8e8434bc630f9e332d2060184abfa8981488dc7 Mon Sep 17 00:00:00 2001 From: fujie Date: Sat, 3 Jan 2026 10:55:05 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=BC=95=E5=85=A5=E9=80=89=E9=A1=B9?= =?UTF-8?q?=E4=BB=A5=E5=9C=A8=E5=8F=91=E5=B8=83=E8=AF=B4=E6=98=8E=E4=B8=AD?= =?UTF-8?q?=E5=BF=BD=E7=95=A5=E5=B7=B2=E7=A7=BB=E9=99=A4=E7=9A=84=E6=8F=92?= =?UTF-8?q?=E4=BB=B6=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/release.yml | 2 +- scripts/extract_plugin_versions.py | 27 +++++++++++++++++++-------- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 07486c0..a17ebc9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -101,7 +101,7 @@ jobs: fi # Compare versions and generate release notes - python scripts/extract_plugin_versions.py --compare old_versions.json --output changes.md + python scripts/extract_plugin_versions.py --compare old_versions.json --ignore-removed --output changes.md python scripts/extract_plugin_versions.py --compare old_versions.json --json --output changes.json echo "=== Version Changes ===" diff --git a/scripts/extract_plugin_versions.py b/scripts/extract_plugin_versions.py index dda79a6..3a6f3ed 100644 --- a/scripts/extract_plugin_versions.py +++ b/scripts/extract_plugin_versions.py @@ -109,9 +109,7 @@ def scan_plugins_directory(plugins_dir: str) -> list[dict[str, Any]]: return plugins -def compare_versions( - current: list[dict], previous_file: str -) -> dict[str, list[dict]]: +def compare_versions(current: list[dict], previous_file: str) -> dict[str, list[dict]]: """ Compare current plugin versions with a previous version file. 比较当前插件版本与之前的版本文件。 @@ -168,7 +166,9 @@ def format_markdown_table(plugins: list[dict]) -> str: "|---------------|----------------|-------------|---------------------|", ] - for plugin in sorted(plugins, key=lambda x: (x.get("type", ""), x.get("title", ""))): + for plugin in sorted( + plugins, key=lambda x: (x.get("type", ""), x.get("title", "")) + ): title = plugin.get("title", "Unknown") version = plugin.get("version", "Unknown") plugin_type = plugin.get("type", "Unknown").capitalize() @@ -181,7 +181,9 @@ def format_markdown_table(plugins: list[dict]) -> str: return "\n".join(lines) -def format_release_notes(comparison: dict[str, list]) -> str: +def format_release_notes( + comparison: dict[str, list], ignore_removed: bool = False +) -> str: """ Format version comparison as release notes. 将版本比较格式化为发布说明。 @@ -206,7 +208,7 @@ def format_release_notes(comparison: dict[str, list]) -> str: ) lines.append("") - if comparison["removed"]: + if comparison["removed"] and not ignore_removed: lines.append("### 移除插件 / Removed Plugins") for plugin in comparison["removed"]: lines.append(f"- **{plugin['title']}** v{plugin['version']}") @@ -239,6 +241,11 @@ def main(): metavar="FILE", help="Compare with previous version JSON file", ) + parser.add_argument( + "--ignore-removed", + action="store_true", + help="Ignore removed plugins in output", + ) parser.add_argument( "--output", "-o", @@ -257,7 +264,9 @@ def main(): if args.json: output = json.dumps(comparison, indent=2, ensure_ascii=False) else: - output = format_release_notes(comparison) + output = format_release_notes( + comparison, ignore_removed=args.ignore_removed + ) if not output.strip(): output = "No changes detected. / 未检测到更改。" elif args.json: @@ -268,7 +277,9 @@ def main(): # Default: simple list lines = [] for plugin in sorted(plugins, key=lambda x: x.get("title", "")): - lines.append(f"{plugin.get('title', 'Unknown')}: v{plugin.get('version', '?')}") + lines.append( + f"{plugin.get('title', 'Unknown')}: v{plugin.get('version', '?')}" + ) output = "\n".join(lines) # Write output