-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
futrime
committed
Feb 12, 2024
1 parent
9c5652c
commit 2f0f906
Showing
1 changed file
with
66 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |