plugin fetcher

This commit is contained in:
Chipmunk 2024-06-14 16:16:03 -04:00
parent 40cb82abea
commit 284a22d109
2 changed files with 21 additions and 0 deletions

Binary file not shown.

21
scripts/fetch_mods.sh Executable file
View file

@ -0,0 +1,21 @@
compile_gradle () { # fetch_git_repo_and_compile_gradle sounded too long
git clone --depth 1 "$@" mod_files
cd mod_files/
./gradlew --no-daemon build
cp "$(ls build/libs/*.jar | awk '{print length($0)"\t"$0}' | sort -n | cut -f2- | head -n 1)" ../ # partially skidded from ai
cd ../
rm -rf mod_files/
}
fetch_github_releases () {
tag="$(curl "https://github.com/$1/releases?q=$2&expanded=true" | grep -oE '"/'$1'/releases/tag/[^"]+"' | cut -f 6 -d '/' | tr -d '"')"
jars="$(curl -L -H 'Accept: application/vnd.github+json' https://api.github.com/repos/$1/releases/tags/$tag | grep -oE '"https://github.com/'$1'/[^"]+\.jar"' | tr -d '"')"
curl -OJL "$(echo $jars | awk '{print length($0)"\t"$0}' | sort -n | cut -f2- | head -n 1)"
}
mkdir fetched_mods
cd fetched_mods
fetch_github_releases 'FabricMC/fabric' '20w14infinite'