Skip to content

Commit

Permalink
chore: add changelog automation
Browse files Browse the repository at this point in the history
  • Loading branch information
Zijian Zhang committed Jan 29, 2024
1 parent dbbb01e commit f81c05b
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions scripts/validate_release.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import argparse
import re
import subprocess
from typing import TypedDict


Expand Down Expand Up @@ -31,6 +32,7 @@ def get_args() -> Args:
"tag": args.tag,
}


def get_changelog_current_version_content(version: str) -> str:
with open("CHANGELOG.md", "r", encoding="utf-8") as f:
content = f.read()
Expand All @@ -41,20 +43,27 @@ def get_changelog_current_version_content(version: str) -> str:

if not result:
raise Exception("CHANGELOG.md lacks version {}".format(version))

return result.group(1)


def validate_changelog(version: str):
try:
subprocess.run(
f"npx changelog --format markdownlint",
shell=True,
check=True,
)
except subprocess.CalledProcessError as e:
print("Have you installed it by `npm i -g keep-a-changelog`?")
raise e

with open("CHANGELOG.md", "r", encoding="utf-8") as f:
content = f.read()

if not re.search(r"## \[{}\]".format(version), content):
raise Exception("CHANGELOG.md lacks version {}".format(version))

if not re.search(r"\[{}\]:".format(version), content):
raise Exception("CHANGELOG.md lacks version link {}".format(version))


def validate_tooth_json(version: str):
with open("tooth.json", "r", encoding="utf-8") as f:
Expand Down

0 comments on commit f81c05b

Please sign in to comment.