diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index bf753c4..dbe69ad 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -32,6 +32,21 @@ jobs: website: "https://greenboi.me" categories: "mods maps tools items" - run: echo ${{ steps.pub.outputs.url }} + - uses: actions/checkout@v3 + - id: pub_prebuilt + uses: ./ + with: + namespace: GreenTF + description: Test + dev: true + token: ${{ secrets.TS_KEY }} + name: test + version: 0.${{ github.run_number }}.1 + community: test # needs to be test for thunderstore.dev + file: test_zip.zip + + + # publish: diff --git a/Dockerfile b/Dockerfile index a29ba19..ed5ae7d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,4 +8,5 @@ RUN ["mv", "-v", "tcli-0.1.4-linux-x64/tcli", "/bin/tcli"] COPY ./entrypoint.sh /entrypoint.sh COPY ./cfg_edit.js /cfg_edit.js RUN ["chmod", "+x", "/entrypoint.sh"] +RUN ["deno", "cache", "/cfg_edit.js"] ENTRYPOINT ["/entrypoint.sh"] diff --git a/README.md b/README.md index 580b3fd..c24bded 100644 --- a/README.md +++ b/README.md @@ -48,9 +48,10 @@ Check the wiki [here](https://github.com/GreenTF/upload-thunderstore-package/wik | `name` | Name of the package. | `true` | | `description` | Description of the package that will appear on Thunderstore. | `true` | | `version` | Package version in SemVer format. | `true` | +| `file` | Path to a prebuilt zip file. Will skip the build step if provided. | `false` | | `path` | Path of the files to package. Useful when using build artifacts from other steps. Defaults to using the contents of the repo. | `false` | | `icon` | URL to download the icon from. Will try to find `icon.png` in the root of the repo if not provided. | `false` | -| `readme` | URL to download the readme from. Will try to fine `README.md` in the root of the repo if not provided. | `false` | +| `readme` | URL to download the readme from. Will try to find `README.md` in the root of the repo if not provided. | `false` | | `dev` | Publish to https://thunderstore.dev if set, https://thunderstore.io if not set. | `false` | | `wrap` | Directory to wrap the contents of the repo in. By default the contents of the root of the repo will be in the root of the package. | `false` | | `categories` | A list, separated by spaces of categories to give to the mod when published. These must be available in the community you're publishing to. | `false` | diff --git a/action.yml b/action.yml index ebe4a0c..361bdfd 100644 --- a/action.yml +++ b/action.yml @@ -42,12 +42,14 @@ inputs: description: 'List of dependencies by name & version' nsfw: description: 'Is the mod NSFW' + file: + description: 'Prebuilt .zip file to use, relative to the repo root' outputs: url: description: 'URL of uploaded mod' runs: using: docker - image: Dockerfile + image: ghcr.io/greentf/utp:latest env: TCLI_AUTH_TOKEN: ${{ inputs.token }} TS_COMMUNITY: ${{ inputs.community }} @@ -64,3 +66,4 @@ runs: TS_CATEGORIES: ${{ inputs.categories }} TS_DEPS: ${{ inputs.deps }} TS_NSFW: ${{ inputs.nsfw }} + TS_FILE: ${{ inputs.file }} diff --git a/cfg_edit.js b/cfg_edit.js index a7c7fde..f703681 100644 --- a/cfg_edit.js +++ b/cfg_edit.js @@ -1,9 +1,4 @@ -import * as TOML from "https://unpkg.com/@aduh95/toml@0.4.2/web/toml2js.js"; - -//init toml parser for some reason idk there was no Deno native module -await TOML.default(); - - +import * as TOML from "npm:@aduh95/toml@0.4.2"; //Read in thunderstore.toml const tstore = TOML.parse(await Deno.readTextFile("./thunderstore.toml")); diff --git a/entrypoint.sh b/entrypoint.sh index 9d33e7d..b1c4e4d 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -68,16 +68,26 @@ function publish() { else repo="https://thunderstore.io" fi - echo "::group::Build and publish" - tcli build - echo "Publish to $repo" - out=$(tcli publish --repository ${repo} --file build/*.zip) #capture the output to get the URL + + # skip the build if there is a prebuilt package provided + if [ -n "$TS_FILE" ]; then + echo "::group::Publish package" + echo "Publish to $repo" + file="dist/$TS_FILE" + else + echo "::group::Build and publish" + tcli build + echo "Publish to $repo" + file="build/*.zip" + fi + + out=$(tcli publish --repository ${repo} --file ${file}) #capture the output to get the URL # A bad response from the server doesn't exit with a non-zero status code if [[ $? -ne 0 ]]; then echo "::error::$(echo ${out} | grep -Eo ERROR:.*)" exit 1 fi - echo "::set-output name=url::$(echo ${out} | grep -Eo "https.*")" + echo "url=$(echo ${out} | grep -Eo "https.*")" >> $GITHUB_OUTPUT echo "Done!" echo "::endgroup::" } diff --git a/test_zip.zip b/test_zip.zip new file mode 100644 index 0000000..f928b2b Binary files /dev/null and b/test_zip.zip differ