diff --git a/.github/workflows/build_head.yml b/.github/workflows/build_head.yml new file mode 100644 index 0000000..8350379 --- /dev/null +++ b/.github/workflows/build_head.yml @@ -0,0 +1,34 @@ +name: release +on: + workflow_dispatch: + push: + branches: + - '**' + tags-ignore: + - '*.*' + pull_request: + branches: + - '**' + tags-ignore: + - '*.*' +jobs: + build: + runs-on: ubuntu-latest + steps: + - id: vars + run: | + echo ::set-output name=VERSION::build-${GITHUB_RUN_NUMBER}-git-${GITHUB_SHA:0:7} + - uses: actions/checkout@v2 + - uses: actions/setup-python@v3 + with: + python-version: 3.x + - run: chmod +x megane + - run: ./megane bundle + env: + MOD_VERSION: ${{ steps.vars.outputs.VERSION }} + - uses : actions/upload-artifact@v2 + with : + name : megane-${{ steps.vars.outputs.VERSION }} + path : | + output/*.jar + input/META-INF/jars/*.jar \ No newline at end of file diff --git a/.github/workflows/build_release.yml b/.github/workflows/build_release.yml new file mode 100644 index 0000000..bc12f16 --- /dev/null +++ b/.github/workflows/build_release.yml @@ -0,0 +1,31 @@ +name: release +on: + push: + tags: "*" +jobs: + build: + runs-on: ubuntu-latest + steps: + - id: vars + run: | + echo ::set-output name=VERSION::${GITHUB_REF#refs/*/} + - uses: actions/checkout@v2 + - uses: actions/setup-python@v3 + with: + python-version: 3.x + - run: chmod +x megane + - run: ./megane bundle curseforge + env: + MOD_VERSION: ${{ steps.vars.outputs.VERSION }} + CURSEFORGE_API: ${{ secrets.CURSEFORGE_API }} + - uses: alexellis/upload-assets@0.2.2 + env: + GITHUB_TOKEN: ${{ github.token }} + with: + asset_paths: '["output/*.jar", "input/META-INF/jars/*.jar"]' + - uses : actions/upload-artifact@v2 + with : + name : megane-${{ steps.vars.outputs.VERSION }} + path : | + output/*.jar + input/META-INF/jars/*.jar \ No newline at end of file diff --git a/megane b/megane new file mode 100755 index 0000000..51b55b5 --- /dev/null +++ b/megane @@ -0,0 +1,8 @@ +#!/usr/bin/sh + +pip3 install urllib3 > /dev/null 2>&1 + +for arg in "$@"; do + echo "Running $arg" + python3 "./scripts/${arg}.py" +done \ No newline at end of file diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 81d8a95..0000000 --- a/requirements.txt +++ /dev/null @@ -1 +0,0 @@ -urllib3 \ No newline at end of file diff --git a/bundle.py b/scripts/bundle.py similarity index 97% rename from bundle.py rename to scripts/bundle.py index dbbfe95..bddbc4d 100644 --- a/bundle.py +++ b/scripts/bundle.py @@ -6,7 +6,7 @@ from inspect import cleandoc from urllib.request import Request, urlopen import properties as prop -from util import get_script_dir +from util import get_base_dir mod_metadata = { @@ -39,7 +39,7 @@ "jars": [] } -script_dir = get_script_dir() +script_dir = get_base_dir() input_dir = f"{script_dir}/input" output_dir = f"{script_dir}/output" diff --git a/curseforge.py b/scripts/curseforge.py similarity index 97% rename from curseforge.py rename to scripts/curseforge.py index fc56862..79eaf7c 100644 --- a/curseforge.py +++ b/scripts/curseforge.py @@ -4,10 +4,10 @@ from urllib3 import encode_multipart_formdata import properties as prop from properties import CurseForge -from util import get_script_dir +from util import get_base_dir -script_dir = get_script_dir() +script_dir = get_base_dir() api_token = environ["CURSEFORGE_API"] api_base_url = "https://minecraft.curseforge.com/api" diff --git a/properties.py b/scripts/properties.py similarity index 93% rename from properties.py rename to scripts/properties.py index 626a995..cb85be6 100644 --- a/properties.py +++ b/scripts/properties.py @@ -1,4 +1,7 @@ -version = "7.2.0" +from os import environ + + +version = environ.get("MOD_VERSION") or "local" minecraft_version = "1.18.2" dependencies = { diff --git a/scripts/util.py b/scripts/util.py new file mode 100644 index 0000000..a8f8a7c --- /dev/null +++ b/scripts/util.py @@ -0,0 +1,6 @@ +import sys +from os.path import dirname, realpath + + +def get_base_dir(): + return dirname(dirname(realpath(sys.argv[0]))) diff --git a/util.py b/util.py deleted file mode 100644 index 5c4dc08..0000000 --- a/util.py +++ /dev/null @@ -1,6 +0,0 @@ -import sys -from os.path import dirname, realpath - - -def get_script_dir(): - return dirname(realpath(sys.argv[0]))