restore from backup
This commit is contained in:
commit
ad483a1403
11 changed files with 208 additions and 0 deletions
86
release.py
Normal file
86
release.py
Normal file
|
|
@ -0,0 +1,86 @@
|
|||
import os
|
||||
import ast
|
||||
import json
|
||||
import shutil
|
||||
import hashlib
|
||||
|
||||
CODE_REPO = "https://git.thooloo.net/CthulhuOnIce/Kraken"
|
||||
|
||||
# this program compiles Kraken (in a git repository in kraken-code) and does all the processing required for versioning and release
|
||||
|
||||
def confirm(message):
|
||||
response = input(f"{message} (y/n): ")
|
||||
return response.lower() == "y"
|
||||
|
||||
def continue_or_exit(message):
|
||||
return confirm(f"{message} Continue?")
|
||||
|
||||
# check for essentials
|
||||
def code_repo_exists():
|
||||
if not os.path.exists("Kraken-Code"):
|
||||
return False
|
||||
if not os.path.exists("Kraken-Code/.git"):
|
||||
return False
|
||||
if not os.path.exists("Kraken-Code/build.bat"):
|
||||
return False
|
||||
if not os.path.exists("Kraken-Code/src"):
|
||||
return False
|
||||
if not os.path.exists("Kraken-Code/kraken.py"):
|
||||
return False
|
||||
return True
|
||||
|
||||
if not code_repo_exists():
|
||||
delete_and_clone = confirm("Kraken-Code does not exist or is not a valid Kraken repository. Delete and clone?")
|
||||
if delete_and_clone:
|
||||
shutil.rmtree("Kraken-Code", ignore_errors=True)
|
||||
os.system(f"git clone {CODE_REPO} Kraken-Code")
|
||||
|
||||
os.system("cd Kraken-Code && .\\build.bat --silent")
|
||||
|
||||
buildinfo = {}
|
||||
|
||||
build_py_path = os.path.join("Kraken-Code", "src", "buildinfo.py")
|
||||
if os.path.exists(build_py_path):
|
||||
AST = ast.parse(open(build_py_path, "r").read())
|
||||
for node in AST.body:
|
||||
if isinstance(node, ast.Assign):
|
||||
buildinfo[node.targets[0].id] = node.value.value
|
||||
else:
|
||||
continue_or_exit("No buildinfo.py found, no build info will be provided with the release.")
|
||||
|
||||
# VERSION_NUMBER = "3.0.0"
|
||||
# PRE_RELEASE = True
|
||||
utils_path = os.path.join("Kraken-Code", "src", "utils.py")
|
||||
if os.path.exists(utils_path):
|
||||
AST = ast.parse(open(utils_path, "r").read())
|
||||
for node in AST.body:
|
||||
if isinstance(node, ast.Assign):
|
||||
if node.targets[0].id in ["VERSION_NUMBER", "PRE_RELEASE"]:
|
||||
buildinfo[node.targets[0].id] = node.value.value
|
||||
|
||||
release_folder = "Release" if not buildinfo["PRE_RELEASE"] else "PreRelease"
|
||||
if os.path.exists(release_folder):
|
||||
shutil.rmtree(release_folder, ignore_errors=True)
|
||||
os.mkdir(release_folder)
|
||||
|
||||
dist_path = os.path.join("Kraken-Code", "dist", "kraken.exe")
|
||||
if os.path.exists(dist_path):
|
||||
md5 = hashlib.md5(open(dist_path, "rb").read()).hexdigest()
|
||||
buildinfo["MD5"] = md5
|
||||
shutil.copy(dist_path, f"{release_folder}/kraken.exe")
|
||||
else:
|
||||
continue_or_exit("No kraken.exe found, no binary will be provided with the release.")
|
||||
|
||||
changelog_path = os.path.join("changelog.md")
|
||||
if os.path.exists(changelog_path):
|
||||
shutil.copy(changelog_path, f"{release_folder}/README.md")
|
||||
else:
|
||||
continue_or_exit("No changelog.md found, no changelog will be provided with the release.")
|
||||
|
||||
for key in buildinfo:
|
||||
print(f"{key}: {buildinfo[key]}")
|
||||
|
||||
with open(f"{release_folder}/buildinfo.json", "w") as f:
|
||||
f.write(json.dumps(buildinfo, indent=2))
|
||||
|
||||
print("Release ready! Git commit and push to make public.")
|
||||
Loading…
Add table
Add a link
Reference in a new issue