Skip to content

Commit

Permalink
Dev (#21)
Browse files Browse the repository at this point in the history
* fix: allow for categories with spaces

* fix: trim version properly in entrypoint script

* feat: move tcli to separate image

* fix: add ca-certificates package

* add debug to edit script

* fix: pass categories and description as args rather than env vars

* fix: use args for cfg_edit.js too

* fix: don't remove newline characters

* fix: include wget in tcli image

* chore: add tests for publishing prebuilt mods

* checkout again before second test

* don't skip config step with prebuilt file

* fix: limit description field to 256 characters

* add categories for second test

* remove prebuilt test
  • Loading branch information
AnActualEmerald authored May 2, 2023
1 parent b338183 commit f724966
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 25 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Action Image CI
name: Build TCLI Image

on:
workflow_dispatch:
Expand All @@ -19,7 +19,7 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: Build the Docker image
run: docker build . --file Dockerfile --tag ghcr.io/greentf/utp:latest
run: docker build . --file Dockerfile.tcli --tag ghcr.io/greentf/tcli:latest
- name: Authenticate with GHCR
if: ${{ github.event_name == 'release' || github.event.inputs.push == 'true' }}
uses: docker/login-action@v2.1.0
Expand All @@ -29,4 +29,4 @@ jobs:
password: ${{ secrets.GHCR_TOKEN }}
- name: Push container
if: ${{ github.event_name == 'release' || github.event.inputs.push == 'true' }}
run: docker push ghcr.io/greentf/utp:latest
run: docker push ghcr.io/greentf/tcli:latest
19 changes: 15 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- main
- dev
pull_request:
branches:
- main
Expand All @@ -22,15 +23,25 @@ jobs:
uses: ./
with:
namespace: GreenTF
description: Test
name: Test
dev: true
token: ${{ secrets.TS_KEY }}
name: test
version: 0.${{ github.run_number }}.0
description: |
The FitnessGram Pacer test is a multistage aerobic capacity test that progressively gets more difficult as it continues.
The 20 meter Pacer test will begin in 30 seconds.
Line up at the start. The running speed starts slowly, but gets faster each minute after you hear this signal *boop*.
A single lap should be completed each time you hear this sound *ding*. Remember to run in a straight line, and run as long as possible.
The second time you fail to complete a lap before the sound, your test is over. The test will begin on the word start.
On your mark, get ready, start.
version: v0.${{ github.run_number }}.0
community: test # needs to be test for thunderstore.dev
wrap: mods
website: "https://greenboi.me"
categories: "mods maps tools items"
categories: |
mods
maps
tools
items
- run: echo ${{ steps.pub.outputs.url }}


Expand Down
15 changes: 7 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
FROM denoland/deno as setup
WORKDIR /
RUN ["apt", "update", "-yy"]
RUN ["apt", "install", "wget", "-yy"]
RUN ["wget", "-O", "tcli.tar.gz", "https://github.com/thunderstore-io/thunderstore-cli/releases/download/0.2.1/tcli-0.2.1-linux-x64.tar.gz"]
RUN ["tar", "xvf", "tcli.tar.gz"]
RUN ["mv", "-v", "tcli-0.2.1-linux-x64/tcli", "/bin/tcli"]
FROM denoland/deno as cache
ENV DENO_DIR=/var/tmp/deno_cache
COPY ./cfg_edit.js /cfg_edit.js
RUN deno cache /cfg_edit.js
FROM ghcr.io/greentf/tcli
ENV DENO_DIR=/var/tmp/deno_cache
COPY --from=cache ${DENO_DIR} ${DENO_DIR}
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"]
6 changes: 6 additions & 0 deletions Dockerfile.tcli
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM denoland/deno
RUN apt-get update && apt-get install -y wget && rm -rf /var/lib/apt/lists/*
RUN ["wget", "-O", "tcli.tar.gz", "https://github.com/thunderstore-io/thunderstore-cli/releases/download/0.2.1/tcli-0.2.1-linux-x64.tar.gz"]
RUN ["tar", "xvf", "tcli.tar.gz"]
RUN ["mv", "-v", "tcli-0.2.1-linux-x64/tcli", "/bin/tcli"]
ENTRYPOINT ["/bin/bash"]
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ jobs:
name: test # the name of the package
version: $GITHUB_REF_NAME # Use the tag as the package version
community: Northstar
categories: | # <-- notice this pipe character
Foo
Bar: Baz
```
## Getting a Thunderstore token
Expand All @@ -54,10 +58,10 @@ Check the wiki [here](https://github.com/GreenTF/upload-thunderstore-package/wik
| `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` |
| `categories` | A list, separated by newline characters, of categories to give to the mod when published. These must be available in the community you're publishing to. | `false` |
| `deps` | A list, separated by spaces, of mods this mod depends on. Must be in `namespace-modname@1.2.3` format. The publish will fail if any of these aren't a real package. | `false` |
| `website` | The homepage URL for the mod. Defaults to the github repo URL. | `false`
| `nsfw` | Set this to mark the mod as NSFW | `false` |
| `nsfw` | Set this to `true` mark the mod as NSFW | `false` |

## Outputs
| Output | Description |
Expand Down
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ outputs:
description: 'URL of uploaded mod'
runs:
using: docker
image: docker://ghcr.io/greentf/utp:latest
image: 'Dockerfile'
env:
TCLI_AUTH_TOKEN: ${{ inputs.token }}
TS_COMMUNITY: ${{ inputs.community }}
Expand Down
12 changes: 7 additions & 5 deletions cfg_edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ const tstore = TOML.parse(await Deno.readTextFile("./thunderstore.toml"));
const namespace = Deno.env.get("TS_NAMESPACE");
const name = Deno.env.get("TS_NAME");
const version = Deno.env.get("TS_VERSION").replace(/v/g, '');
const desc = Deno.env.get("TS_DESC");
const desc = Deno.env.get("TS_DESC").substring(0, 256); //truncate overlong descriptions
const homepage = Deno.env.get("TS_WEBSITE");
const categories = Deno.env.get("TS_CATEGORIES").replace(/\n/g, '');
const categories = Deno.env.get("TS_CATEGORIES").replace(/\n/g, ','); //support comma and new-line delimiters
const deps = Deno.env.get("TS_DEPS").replace(/\n/g, ' ');
const community = Deno.env.get("TS_COMMUNITY");
const nsfw = Deno.env.get("TS_NSFW");
Expand All @@ -33,13 +33,15 @@ if (homepage && homepage !== "") {
tstore.package.websiteUrl = `${Deno.env.get("GITHUB_SERVER_URL")}/${Deno.env.get("GITHUB_REPOSITORY")}`;
}

if (nsfw && nsfw !== "" ) {
if (nsfw && nsfw === "true" ) {
tstore.package.containsNsfwContent = true
}

if (categories && categories !== "") {
//only keep truthy elements from the split
tstore.publish.categories = categories.split(' ').filter(e => e).map(e=> e.toLowerCase());
console.log(`::debug::Parsing categories: ${categories}`);
tstore.publish.categories = categories.split(',')
.filter(e => e) //only keep truthy elements
.map(e=> e.toLowerCase().trim());
}

if (deps && deps !== "") {
Expand Down
3 changes: 1 addition & 2 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/bin/bash

function setup() {
echo "::group::Set up environment"

Expand Down Expand Up @@ -46,7 +45,7 @@ function configure(){

#tcli usage based off of https://github.com/R2Northstar/Northstar/blob/d8ad8f12f8bca1e8de96f5d7163f71997d487218/.github/workflows/build.yml#L132-L192
echo "Init tcli config"
tcli init --package-name ${TS_NAME} --package-namespace ${TS_NAMESPACE} --package-version ${TS_VERSION}
tcli init --package-name ${TS_NAME} --package-namespace ${TS_NAMESPACE} --package-version ${TS_VERSION#v}

if [ -n "$TS_DEV" ]; then
TS_COMMUNITY="test"
Expand Down

0 comments on commit f724966

Please sign in to comment.