diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..b1bdd00 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,36 @@ +name: Build Project + +on: + push: + branches: + - main # Change this to your preferred branch + pull_request: + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Set up JDK + uses: actions/setup-java@v2 + with: + java-version: '16' # Change to '8' for Java 8 + + - name: Install BusyBox and 7z + run: | + sudo apt-get update + sudo apt-get install -y busybox p7zip-full + + - name: Install Go + uses: actions/setup-go@v2 + with: + go-version: '1.20' # Specify the Go version you need + + - name: Update Packwiz + run: make update-packwiz + + - name: Make Modpack + run: make preClean multimc curseforge modrinth postClean \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..474bbbb --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,76 @@ +name: Build Project + +on: + push: + tags: + - 'v*' + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Set up JDK + uses: actions/setup-java@v2 + with: + java-version: '16' # Change to '8' for Java 8 + + - name: Install BusyBox and 7z + run: | + sudo apt-get update + sudo apt-get install -y busybox p7zip-full + + - name: Install Go + uses: actions/setup-go@v2 + with: + go-version: 'latest' # Always use the latest Go version + + - name: Update Packwiz + run: make update-packwiz + + - name: Make Modpack + run: make preClean multimc curseforge modrinth postClean + + - name: Create Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.ref }} + release_name: ${{ github.ref }} + draft: false + prerelease: false + + - name: Upload MultiMC Release Asset + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: .build/*-multimc.zip + asset_name: multimc.zip + asset_content_type: application/zip + + - name: Upload CurseForge Release Asset + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: .build/*-curseforge.zip + asset_name: curseforge.zip + asset_content_type: application/zip + + - name: Upload Modrinth Release Asset + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: .build/*-modrinth.mrpack + asset_name: modrinth.mrpack + asset_content_type: application/octet-stream \ No newline at end of file diff --git a/.gitignore b/.gitignore index c8d7bd8..857f17c 100644 --- a/.gitignore +++ b/.gitignore @@ -9,7 +9,11 @@ .minecraft/realms_persistence.json ## Ignore Modpack Updater Script loose files +.build +.run +.server .technic + *.zip *.mrpack diff --git a/.minecraft/modpack-template_icon.png b/.minecraft/icon.png similarity index 100% rename from .minecraft/modpack-template_icon.png rename to .minecraft/icon.png diff --git a/.minecraft/index.toml b/.minecraft/index.toml index 251b5b5..d8b4564 100644 --- a/.minecraft/index.toml +++ b/.minecraft/index.toml @@ -1,14 +1,14 @@ hash-format = "sha256" +[[files]] +file = "icon.png" +hash = "50f74a7debb4a852e1384434500515f2478b8dcf0d71b75eba148ca34d89715c" + [[files]] file = "icons/images.png.pw.toml" hash = "a779f12ed53f4af7c51b914dcc3722bb9b14508bf3b49b49408853f5ee78c52e" metafile = true -[[files]] -file = "modpack-template_icon.png" -hash = "50f74a7debb4a852e1384434500515f2478b8dcf0d71b75eba148ca34d89715c" - [[files]] file = "mods/lithium.pw.toml" hash = "b3b33c53f8356928f86223f26eaebd7a266d610f8628e5077cda196192b0b7e4" diff --git a/.minecraft/pack.toml b/.minecraft/pack.toml index 4935dc7..b0a89bc 100644 --- a/.minecraft/pack.toml +++ b/.minecraft/pack.toml @@ -6,7 +6,7 @@ pack-format = "packwiz:1.1.0" [index] file = "index.toml" hash-format = "sha256" -hash = "3ad9c66d0812efb7f388bdbf2c913670aec193da576563d97bccc33db54b06c2" +hash = "16610c083ce2ed510a301da5867d023e0d81cbbd2c1603e017827d7130e3234d" [versions] fabric = "0.16.4" diff --git a/Makefile b/Makefile index 5b29ab7..779cb22 100644 --- a/Makefile +++ b/Makefile @@ -2,83 +2,79 @@ default: @echo "No Default make command configured" @echo "Please use either" @echo " - make multimc" + @echo " - make local multimc" @echo " - make curseforge" @echo " - make modrinth" + @echo " - make local technic" @echo " - make technic" @echo " - make server" @echo " - make all" @echo "" - @echo "Curseforge will make a curseforge import file" - @echo "" - @echo "Modrinth will make a modrinth import file" - @echo "" - @echo "Multimc will make a multimc zip file which contains" - @echo " the packwiz updater" - @echo "" - @echo "Technic will make a technic pack zip" - @echo "" - @echo "Server will make a server pack zip" - @echo " This will include the packwiz updater," - @echo " but will not be configured to run by default" - @echo "" - @echo "All will make all packs it can" - @echo "" -PACKNAME := $(notdir $(CURDIR)) +PACKNAME := $(notdir $(shell pwd)) +ICONNAME := $(shell echo $(PACKNAME) | sed 's/[^a-zA-Z0-9]/_/g') PACKURL := $(shell pw detect) -curseforge: refresh - -mkdir .build +build: refresh + @mkdir -p .build + @echo "PACKNAME: ${PACKNAME}" + @echo "ICONNAME: ${ICONNAME}" + @echo "PACKURL: ${PACKURL}" + +curseforge: build @echo "Making Curseforge pack" packwiz curseforge export --pack-file .minecraft/pack.toml mv ./*.zip ./.build/${PACKNAME}-curseforge.zip -modrinth: refresh - -mkdir .build +modrinth: build @echo "Making Modrinth pack" - packwiz modrinth export --pack-file .minecraft/pack.toml + packwiz modrinth export --pack-file .minecraft/pack.toml mv ./*.mrpack ./.build/${PACKNAME}-modrinth.mrpack -multimc: refresh - -mkdir .build +multimc: build @echo "Making MultiMC pack" + cp .minecraft/icon.png ./${ICONNAME}_icon.png 7z d .build/${PACKNAME}-multimc.zip ./* -r 7z d .build/${PACKNAME}-multimc.zip ./.minecraft -r @sed -i 's#{PACKURL}#${PACKURL}#' instance.cfg + @sed -i 's#{ICONNAME}#${ICONNAME}#' instance.cfg 7z a .build/${PACKNAME}-multimc.zip ./* -r 7z a .build/${PACKNAME}-multimc.zip ./.minecraft -r 7z d .build/${PACKNAME}-multimc.zip ./.build ./.minecraft/mods ./.minecraft/pack.toml ./.minecraft/index.toml -r + rm ./${ICONNAME}_icon.png @sed -i 's#${PACKURL}#{PACKURL}#' instance.cfg + @sed -i 's#${ICONNAME}#{ICONNAME}#' instance.cfg -technic: refresh - -mkdir .build +# Technic targets +technic: build @echo "Making Technic pack" + @mkdir -p .technic -rm -rf .technic - -cp -r .minecraft .technic - cp ${PACKNAME}_icon.png .technic/icon.png + cp -r .minecraft .technic + cp .minecraft/icon.png .technic/icon.png cd .technic && java -jar ../.minecraft/packwiz-installer-bootstrap.jar ../.minecraft/pack.toml && cd .. -rm -rf .technic/packwiz* .technic/index.toml .technic/pack.toml .technic/mods/*.toml 7z d .build/${PACKNAME}-technic.zip ./* ./.* -r 7z a .build/${PACKNAME}-technic.zip ./.technic/* -r -server: refresh - -mkdir .build +# Server target +server: build @echo "Making Server pack" -rm -rf .server - -cp -r .minecraft .server - cp ${PACKNAME}_icon.png .server/server-icon.png + @mkdir -p .server + mc-server-icon --icon .minecraft/icon.png --output .server/server-icon.png cd .server && java -jar ../.minecraft/packwiz-installer-bootstrap.jar -s server ../.minecraft/pack.toml && cd .. 7z d .build/${PACKNAME}-server.zip ./* ./.* -r 7z a .build/${PACKNAME}-server.zip ./.server/* -r -preClean: refresh - -rm -rf .build - -rm -rf .server -postClean: refresh - -rm -rf .technic - -rm -rf .server +preClean: + -rm -rf .build .server .technic + -rm -f ./instance.cfga* + +postClean: -git gc --aggressive --prune + clean: preClean postClean all: preClean curseforge modrinth multimc technic server postClean @@ -89,12 +85,18 @@ refresh: update-packwiz: go install github.com/packwiz/packwiz@latest go install github.com/Merith-TK/packwiz-wrapper/cmd/pw@main + go install github.com/Merith-TK/utils/cmd/mc-server-icon@main clear @echo "Packwiz has been Updated" run-server: - cd .minecraft && pw refresh && cd .. - -mkdir .run - echo "eula=true" > .run/eula.txt - cd .run && java -jar ../.minecraft/packwiz-installer-bootstrap.jar ../.minecraft/pack.toml -s server && cd .. - cd .run && java -Xmx2G -Xms2G -jar server.jar nogui && cd .. + @cd .minecraft && pw refresh + @mkdir -p .run + @echo "eula=true" > .run/eula.txt + @mc-server-icon --icon .minecraft/icon.png --output .run/server-icon.png + @cd .run && java -jar ../.minecraft/packwiz-installer-bootstrap.jar ../.minecraft/pack.toml -s server + @if [ ! -f .run/server.jar ]; then \ + echo "Downloading Fabric server jar..."; \ + curl -o .run/server.jar https://meta.fabricmc.net/v2/versions/loader/1.21.1/0.16.5/1.0.1/server/jar; \ + fi + @cd .run && java -Xmx2G -Xms2G -jar server.jar nogui diff --git a/instance.cfg b/instance.cfg index 1f0c6a4..55b212b 100644 --- a/instance.cfg +++ b/instance.cfg @@ -1,5 +1,6 @@ +[General] InstanceType=OneSix -iconKey=modpack.icon +iconKey={ICONNAME}_icon name=Modpack Template OverrideCommands=true PreLaunchCommand="$INST_JAVA" -jar packwiz-installer-bootstrap.jar {PACKURL} \ No newline at end of file diff --git a/modpack-template_icon.png b/modpack-template_icon.png deleted file mode 100644 index d81d8c4..0000000 Binary files a/modpack-template_icon.png and /dev/null differ