testing release system
This commit is contained in:
66
tooling.py
66
tooling.py
@@ -1,11 +1,13 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import os, sys, argparse, tempfile, subprocess, shutil, requests
|
||||
from git.repo import Repo
|
||||
from termcolor import cprint
|
||||
|
||||
parser = argparse.ArgumentParser(description="a helper script for liightninggod modpacks")
|
||||
|
||||
parser.add_argument("--export", "-e", help="export modpack zip", action="store_true")
|
||||
parser.add_argument("--export-full", help="export modpack zip with mods folder", action="store_true")
|
||||
parser.add_argument("--release", "-r", help="release modpack version", action="store_true")
|
||||
parser.add_argument("--setup", "-s", help="setup project and install dependencies", action="store_true")
|
||||
parser.add_argument("--force", "-f", help="forces things when needed, like redoing setup", action="store_true")
|
||||
parser.add_argument("--build-pax", help="builds pax from source, even if on a supported platform", action="store_true")
|
||||
@@ -18,6 +20,9 @@ PAX_LATEST_RELEASE = f"{PAX_GITHUB}/releases/latest/download"
|
||||
PAX_LINUX = f"{PAX_LATEST_RELEASE}/pax"
|
||||
PAX_WINDOWS = f"{PAX_LATEST_RELEASE}/pax-windows.zip"
|
||||
|
||||
MODPACK_GITHUB = "https://git.233hfd.com/joey/FishPogPixelmon"
|
||||
MODPACK_RELEASES_URL = "https://git.233hfd.com/api/v1/repos/joey/FishPogPixelmon/releases"
|
||||
|
||||
|
||||
OS = sys.platform
|
||||
|
||||
@@ -29,6 +34,10 @@ def __main__():
|
||||
return
|
||||
elif args.export:
|
||||
print("exporting modpack")
|
||||
export_pack()
|
||||
return
|
||||
elif args.release:
|
||||
release()
|
||||
return
|
||||
|
||||
print(
|
||||
@@ -36,10 +45,48 @@ def __main__():
|
||||
)
|
||||
|
||||
|
||||
# setup
|
||||
def setup_pack():
|
||||
pax()
|
||||
|
||||
|
||||
# release
|
||||
def release():
|
||||
print("releasing modpack")
|
||||
|
||||
if not command_exists("tea"):
|
||||
cprint("gitea cli is not installed - make sure it is installed for your platform", "red")
|
||||
exit(1)
|
||||
|
||||
repo = Repo(WORKING_DIR)
|
||||
if repo.is_dirty():
|
||||
cprint("repo is dirty - commit changes before releasing", "red")
|
||||
exit(1)
|
||||
|
||||
export_pack()
|
||||
|
||||
print("enter the version number for this release")
|
||||
print(f"the last release was: {most_recent_release()}")
|
||||
version = input("version: v")
|
||||
|
||||
subprocess.run(
|
||||
[
|
||||
"tea",
|
||||
"release",
|
||||
"create",
|
||||
"-a",
|
||||
".out/FishPog Pixelmon.zip",
|
||||
f"v{version}",
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
# export
|
||||
def export_pack():
|
||||
subprocess.run(["./pax", "export"])
|
||||
os.rename(".out/FishPog Pixelmon.zip", ".out/FishPog Pixelmon.zip")
|
||||
|
||||
|
||||
# pax
|
||||
def pax():
|
||||
if os.path.isfile(os.path.join(WORKING_DIR, "pax")) and not args.force:
|
||||
@@ -70,12 +117,12 @@ def pax():
|
||||
|
||||
def pax_from_source():
|
||||
if OS == "windows":
|
||||
print("building from source not supported on windows yet")
|
||||
os._exit(1)
|
||||
cprint("building from source not supported on windows yet", "red")
|
||||
exit(1)
|
||||
|
||||
if not command_exists("nimble"):
|
||||
print("nim is not installed - make sure it is installed for your platform")
|
||||
os._exit(1)
|
||||
cprint("nim is not installed - make sure it is installed for your platform", "red")
|
||||
exit(1)
|
||||
|
||||
TMP = tempfile.mkdtemp()
|
||||
os.chdir(TMP)
|
||||
@@ -87,6 +134,15 @@ def pax_from_source():
|
||||
subprocess.run(["cp", "pax", WORKING_DIR])
|
||||
|
||||
|
||||
# git
|
||||
def most_recent_release() -> str:
|
||||
r = requests.get(MODPACK_RELEASES_URL)
|
||||
releases: list[dict] = r.json()
|
||||
if len(releases) == 0:
|
||||
return "none"
|
||||
return releases[0]["tag_name"]
|
||||
|
||||
|
||||
# helper functions
|
||||
def command_exists(binary_name):
|
||||
return shutil.which(binary_name) is not None
|
||||
|
||||
Reference in New Issue
Block a user