Skip to content

Commit 7688a3c

Browse files
File (#11)
* add `file` input * update README * typo lmao * fix check for file input * update to environment files * update to environment files * test file input * checkout again * use prebuilt container * make file input a relative path * use deno npm interop * deno or whatever * I forgot that I move all the files at the start of the bash script
1 parent ae8dfda commit 7688a3c

File tree

7 files changed

+38
-13
lines changed

7 files changed

+38
-13
lines changed

.github/workflows/test.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,21 @@ jobs:
3232
website: "https://greenboi.me"
3333
categories: "mods maps tools items"
3434
- run: echo ${{ steps.pub.outputs.url }}
35+
- uses: actions/checkout@v3
36+
- id: pub_prebuilt
37+
uses: ./
38+
with:
39+
namespace: GreenTF
40+
description: Test
41+
dev: true
42+
token: ${{ secrets.TS_KEY }}
43+
name: test
44+
version: 0.${{ github.run_number }}.1
45+
community: test # needs to be test for thunderstore.dev
46+
file: test_zip.zip
47+
48+
49+
3550

3651

3752
# publish:

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ RUN ["mv", "-v", "tcli-0.1.4-linux-x64/tcli", "/bin/tcli"]
88
COPY ./entrypoint.sh /entrypoint.sh
99
COPY ./cfg_edit.js /cfg_edit.js
1010
RUN ["chmod", "+x", "/entrypoint.sh"]
11+
RUN ["deno", "cache", "/cfg_edit.js"]
1112
ENTRYPOINT ["/entrypoint.sh"]

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,10 @@ Check the wiki [here](https://github.com/GreenTF/upload-thunderstore-package/wik
4848
| `name` | Name of the package. | `true` |
4949
| `description` | Description of the package that will appear on Thunderstore. | `true` |
5050
| `version` | Package version in SemVer format. | `true` |
51+
| `file` | Path to a prebuilt zip file. Will skip the build step if provided. | `false` |
5152
| `path` | Path of the files to package. Useful when using build artifacts from other steps. Defaults to using the contents of the repo. | `false` |
5253
| `icon` | URL to download the icon from. Will try to find `icon.png` in the root of the repo if not provided. | `false` |
53-
| `readme` | URL to download the readme from. Will try to fine `README.md` in the root of the repo if not provided. | `false` |
54+
| `readme` | URL to download the readme from. Will try to find `README.md` in the root of the repo if not provided. | `false` |
5455
| `dev` | Publish to https://thunderstore.dev if set, https://thunderstore.io if not set. | `false` |
5556
| `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` |
5657
| `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` |

action.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,14 @@ inputs:
4242
description: 'List of dependencies by name & version'
4343
nsfw:
4444
description: 'Is the mod NSFW'
45+
file:
46+
description: 'Prebuilt .zip file to use, relative to the repo root'
4547
outputs:
4648
url:
4749
description: 'URL of uploaded mod'
4850
runs:
4951
using: docker
50-
image: Dockerfile
52+
image: ghcr.io/greentf/utp:latest
5153
env:
5254
TCLI_AUTH_TOKEN: ${{ inputs.token }}
5355
TS_COMMUNITY: ${{ inputs.community }}
@@ -64,3 +66,4 @@ runs:
6466
TS_CATEGORIES: ${{ inputs.categories }}
6567
TS_DEPS: ${{ inputs.deps }}
6668
TS_NSFW: ${{ inputs.nsfw }}
69+
TS_FILE: ${{ inputs.file }}

cfg_edit.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
import * as TOML from "https://unpkg.com/@aduh95/toml@0.4.2/web/toml2js.js";
2-
3-
//init toml parser for some reason idk there was no Deno native module
4-
await TOML.default();
5-
6-
1+
import * as TOML from "npm:@aduh95/toml@0.4.2";
72

83
//Read in thunderstore.toml
94
const tstore = TOML.parse(await Deno.readTextFile("./thunderstore.toml"));

entrypoint.sh

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,16 +68,26 @@ function publish() {
6868
else
6969
repo="https://thunderstore.io"
7070
fi
71-
echo "::group::Build and publish"
72-
tcli build
73-
echo "Publish to $repo"
74-
out=$(tcli publish --repository ${repo} --file build/*.zip) #capture the output to get the URL
71+
72+
# skip the build if there is a prebuilt package provided
73+
if [ -n "$TS_FILE" ]; then
74+
echo "::group::Publish package"
75+
echo "Publish to $repo"
76+
file="dist/$TS_FILE"
77+
else
78+
echo "::group::Build and publish"
79+
tcli build
80+
echo "Publish to $repo"
81+
file="build/*.zip"
82+
fi
83+
84+
out=$(tcli publish --repository ${repo} --file ${file}) #capture the output to get the URL
7585
# A bad response from the server doesn't exit with a non-zero status code
7686
if [[ $? -ne 0 ]]; then
7787
echo "::error::$(echo ${out} | grep -Eo ERROR:.*)"
7888
exit 1
7989
fi
80-
echo "::set-output name=url::$(echo ${out} | grep -Eo "https.*")"
90+
echo "url=$(echo ${out} | grep -Eo "https.*")" >> $GITHUB_OUTPUT
8191
echo "Done!"
8292
echo "::endgroup::"
8393
}

test_zip.zip

35.3 KB
Binary file not shown.

0 commit comments

Comments
 (0)