From 03dca844cb5f9fe14a1a2f62741d061c6d7cd354 Mon Sep 17 00:00:00 2001 From: Joey Eamigh <55670930+JoeyEamigh@users.noreply.github.com> Date: Wed, 21 Jun 2023 17:15:18 -0400 Subject: [PATCH] testing release system --- client/README.md | 17 +++++++++++ client/client.ps1 | 35 ++++++++++++++++++---- client/client.py | 51 ++++++++++++++++++++++++++++++- client/client.sh | 20 ++++++++++--- client/requirements.txt | 4 +++ requirements.txt | 5 ---- tooling.py | 66 +++++++++++++++++++++++++++++++++++++---- venv.ps1 | 5 ++-- venv.sh | 4 +-- 9 files changed, 182 insertions(+), 25 deletions(-) create mode 100644 client/README.md mode change 100644 => 100755 client/client.ps1 mode change 100644 => 100755 client/client.sh delete mode 100644 requirements.txt diff --git a/client/README.md b/client/README.md new file mode 100644 index 0000000..690f0c1 --- /dev/null +++ b/client/README.md @@ -0,0 +1,17 @@ +# FishPog Pixelmon Client + +This tool makes sure the modpack is up to date, and downloads all of the mods. + +## How to use + +### Windows + +```powershell +.\client.ps1 +``` + +### Linux/Mac + +```bash +./client.sh +``` diff --git a/client/client.ps1 b/client/client.ps1 old mode 100644 new mode 100755 index 462b111..db64ba3 --- a/client/client.ps1 +++ b/client/client.ps1 @@ -3,8 +3,9 @@ $winget = Get-Command winget -ErrorAction SilentlyContinue if (!$winget) { Write-Host "Error: winget is not installed." -Foreground Red - Write-Host "This script may not work withotu winget." -Foreground Red - Write-Host "Run 'Add-AppxPackage -RegisterByFamilyName -MainPackage Microsoft.DesktopAppInstaller_8wekyb3d8bbwe' in an admin powershell prompt to install winget." -Foreground Red + Write-Host "This script probably will not work without winget." -Foreground Red + Write-Host "Run 'Add-AppxPackage -RegisterByFamilyName -MainPackage Microsoft.DesktopAppInstaller_8wekyb3d8bbwe' in to install winget." -Foreground Red + Write-Host "If you do install winget, this script should handle the rest." -Foreground Red } # Check that python is installed @@ -36,11 +37,33 @@ if (-not (Get-Command "java" -ErrorAction SilentlyContinue)) { } +# Check that git is installed +if (-not (Get-Command "git" -ErrorAction SilentlyContinue)) { + Write-Host "Error: git is not installed." -Foreground Red + + if ($winget) { + Write-Host "Attempting to install git." + winget install --id Git.Git -e --source winget + } + else { + Write-Host "Please install git to continue." -Foreground Red + exit 1 + } + +} + +# Check that multimc is installed +if (-not (Get-Command "multimc" -ErrorAction SilentlyContinue)) { + Write-Host "Error: multimc is not installed." -Foreground Red + Write-Host "Please install multimc to continue." -Foreground Red + exit 1 +} + if (Test-Path ".venv") { } else { python -m venv .venv } -.venv\Scripts\Activate +. ./.venv/bin/Activate.ps1 -python -m pip install --upgrade pip -python -m pip install -r requirements.txt +(python -m pip install --upgrade pip) | Out-Null +(python -m pip install -r requirements.txt) | Out-Null -python .\client.py \ No newline at end of file +python client.py \ No newline at end of file diff --git a/client/client.py b/client/client.py index 8b55be2..b6618fa 100644 --- a/client/client.py +++ b/client/client.py @@ -1,3 +1,52 @@ #!/usr/bin/env python3 -DOWNLOADER_URL = "https://github.com/North-West-Wind/CurseForge-CLI/releases/latest/download/curseforge.zip" +from termcolor import cprint + +MOD_DOWNLOADER_URL = "https://github.com/North-West-Wind/CurseForge-CLI/releases/latest/download/curseforge.zip" + +REPO_URL = "https://git.233hfd.com/joey/FishPogPixelmon" + + +# main +def __main__(): + header() + warning() + + +# info +def warning(): + cprint( + "This updater may remove your singleplayer worlds. Please use a different instance for singleplayer.", "yellow" + ) + if input("Continue? [Y/n] ").lower() == "n": + exit() + else: + print("") + + +# ascii art lol +def header(): + cprint( + """ + _______ __ __ _______ +| _ ||__|.-----.| |--.| _ |.-----..-----. +|. 1___|| ||__ --|| ||. 1 || _ || _ | +|. __) |__||_____||__|__||. ____||_____||___ | +|: | |: | |_____| +|::.| |::.| +`---' `---' + + _______ __ __ +| _ ||__|.--.--..-----.| |.--------..-----..-----. +|. 1 || ||_ _|| -__|| || || _ || | +|. ____||__||__.__||_____||__||__|__|__||_____||__|__| +|: | +|::.| +`---' + """, + "green", + ) + + +# run app +__main__() diff --git a/client/client.sh b/client/client.sh old mode 100644 new mode 100755 index 485d20d..63a0c6d --- a/client/client.sh +++ b/client/client.sh @@ -12,11 +12,23 @@ if ! [ -x "$(command -v java)" ]; then exit 1 fi -if [ -d .venv ]; then; else python -m venv .venv; fi +# check that git is installed +if ! [ -x "$(command -v git)" ]; then + echo 'Error: git is not installed. Please install it to continue.' >&2 + exit 1 +fi -source .venv/bin/activate +# check that git is installed +if ! [ -x "$(command -v multimc)" ]; then + echo 'Error: multimc is not installed. Please install it to continue.' >&2 + exit 1 +fi -python -m pip install --upgrade pip -python -m pip install -r requirements.txt +if ! [ -d .venv ]; then python -m venv .venv; fi + +source .venv/bin/activate &>/dev/null + +python -m pip install --upgrade pip &>/dev/null +python -m pip install -r requirements.txt &>/dev/null python ./client.py diff --git a/client/requirements.txt b/client/requirements.txt index cf89e54..dd271f4 100644 --- a/client/requirements.txt +++ b/client/requirements.txt @@ -1,5 +1,9 @@ certifi==2023.5.7 charset-normalizer==3.1.0 +gitdb==4.0.10 +GitPython==3.1.31 idna==3.4 requests==2.31.0 +smmap==5.0.0 +termcolor==2.3.0 urllib3==2.0.3 diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index cf89e54..0000000 --- a/requirements.txt +++ /dev/null @@ -1,5 +0,0 @@ -certifi==2023.5.7 -charset-normalizer==3.1.0 -idna==3.4 -requests==2.31.0 -urllib3==2.0.3 diff --git a/tooling.py b/tooling.py index 5515953..77c6722 100644 --- a/tooling.py +++ b/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 diff --git a/venv.ps1 b/venv.ps1 index e63c0d5..e0118b1 100644 --- a/venv.ps1 +++ b/venv.ps1 @@ -1,7 +1,8 @@ # Check for python3 or python if (Get-Command "python3") { $python = "python3" -} else { +} +else { $python = "python" } @@ -15,4 +16,4 @@ if (-Not (Test-Path "./.venv")) { # Install required packages & $python -m pip install --upgrade pip -& $python -m pip install -r requirements.txt \ No newline at end of file +& $python -m pip install -r client/requirements.txt \ No newline at end of file diff --git a/venv.sh b/venv.sh index c287fe3..defad9c 100755 --- a/venv.sh +++ b/venv.sh @@ -1,6 +1,6 @@ #!/bin/bash -if command -v python3 &> /dev/null; then +if command -v python3 &>/dev/null; then python="python3" else python="python" @@ -12,4 +12,4 @@ $python -m venv .venv source .venv/bin/activate $python -m pip install --upgrade pip -$python -m pip install -r requirements.txt +$python -m pip install -r client/requirements.txt