Skip to content

Commit

Permalink
chore: fix validate_release
Browse files Browse the repository at this point in the history
  • Loading branch information
futrime committed Feb 12, 2024
1 parent 9c5652c commit 2f0f906
Showing 1 changed file with 66 additions and 0 deletions.
66 changes: 66 additions & 0 deletions scripts/validate_release.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import argparse
import re
import subprocess
from typing import TypedDict


class Args(TypedDict):
tag: str


def main():
args = get_args()

version = args["tag"].lstrip("v")

validate_changelog(version)
validate_tooth_json(version)


def get_args() -> Args:
parser = argparse.ArgumentParser()
parser.add_argument("--tag", required=True)

args = parser.parse_args()

return {
"tag": args.tag,
}


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))


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

if not re.search(r"\"version\": \"{}\"".format(version), content):
raise Exception("tooth.json has wrong version")

if not re.search(
r"\"https://github.com/LiteLDev/MoreDimensions/releases/download/v{}/more-dimensions-windows-x64.zip\"".format(
version
),
content,
):
raise Exception("tooth.json has wrong version in asset URL")


if __name__ == "__main__":
main()

0 comments on commit 2f0f906

Please sign in to comment.