Files
mc-manager/mc-manager/BUILD.py
T

62 lines
1.7 KiB
Python

#!/usr/bin/python3
import os, datetime
RIDS = [
"linux-x64",
"linux-arm64",
"win-x64",
"win-x86",
"win-arm64"
]
def get_timestamp():
# Yep. We're emulating a bug where our autogenerated timestamps do not have leading zeros
# even though it would be semantically correct to prepend them.
# This has been a bug since the software was created and now we need to keep it,
# lest we break any end user's automatic updating script.
now = datetime.datetime.now(datetime.timezone.utc)
year = now.strftime("%Y")
month_day = int(now.strftime("%m%d"))
hour_min = int(now.strftime("%H%M"))
return f"{year}.{month_day}.{hour_min}"
CURRENT_TIMESTAMP = get_timestamp()
for rid in RIDS:
target_os, arch = rid.split("-")
print(f"=> BUILDING: {rid}")
ret = os.system(rf"dotnet publish --sc true --os {target_os} --arch {arch} -p:Version={CURRENT_TIMESTAMP} -o ./pub/{rid}")
if ret != 0:
raise OSError("Build error")
print(f"==> ZIPPING: {rid}")
if target_os == "win":
os.chdir("./pub")
os.system(rf"zip -r {rid}.zip {rid} >> /dev/null")
os.chdir("..")
continue
os.system(rf"tar czvf ./pub/{rid}.tar.gz -C ./pub/ {rid} >> /dev/null")
os.chdir("pub")
while True:
upload = input(f"Do you want to upload the release assets? Please ensure you have created the tag \"{CURRENT_TIMESTAMP}\" first! (Y/N)")
if upload.lower() not in ["y", "n"]:
print("Please enter either Y or N.")
continue
if upload.lower() == "y":
break
else:
exit()
print("doing the thing")
os.system(rf"echo glob release upload {CURRENT_TIMESTAMP} ./*.tar.gz")