diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index bc81c4a..fdb2a94 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -40,6 +40,8 @@ jobs: maps tools items + deps: | + GreenTF-test@2708437257.35.1 - run: echo ${{ steps.pub.outputs.url }} diff --git a/.github/workflows/test_file.yml b/.github/workflows/test_file.yml new file mode 100644 index 0000000..55c5499 --- /dev/null +++ b/.github/workflows/test_file.yml @@ -0,0 +1,52 @@ +name: Upload Prebuilt Zip + +on: + push: + pull_request: + branches: + - main + workflow_dispatch: + + + +jobs: + test: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: create test zip + run: | + sudo apt install zip + echo "{ \"namespace\": \"GreenTF\", \"name\": \"test\", \"description\": \"Test\", \"version_number\": \"1.${{ github.run_number }}.0\", \"dependencies\": [], \"website_url\": \"https://greenboi.me\" }" >> manifest.json + zip test.zip ./* + - id: pub + uses: ./ + with: + namespace: GreenTF + name: Test + dev: true + token: ${{ secrets.TS_KEY }} + 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: v1.${{ github.run_number }}.0 + community: riskofrain2 + repo: thunderstore.dev + wrap: mods + website: "https://greenboi.me" + categories: | + mods + maps + tools + items + deps: | + GreenTF-Test-0.130.0 + file: ./test.zip + - run: echo ${{ steps.pub.outputs.url }} + diff --git a/cfg_edit.js b/cfg_edit.js index 3148903..74b2dee 100644 --- a/cfg_edit.js +++ b/cfg_edit.js @@ -5,16 +5,17 @@ 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 version = Deno.env.get("TS_VERSION").replace(/v/g, ""); 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(/\s/g, ','); //support comma and new-line delimiters -const deps = Deno.env.get("TS_DEPS").replace(/\n/g, ' '); +const categories = Deno.env.get("TS_CATEGORIES").replace(/\s/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"); const wrap = Deno.env.get("TS_WRAP"); const repo = Deno.env.get("TS_REPO"); +const re = /([a-zA-Z_0-9]*-[a-zA-Z_0-9]*)[\-@](\d+\.\d+\.\d+)/; //these should be set already but we're rewriting the whole file anyways tstore.package.namespace = namespace; @@ -26,45 +27,51 @@ tstore.publish.communities = [community]; tstore.build.copy[0].target = wrap; tstore.package.dependencies = {}; -tstore.publish.repository = repo ?? "https://thunderstore.io" - +tstore.publish.repository = repo ?? "https://thunderstore.io"; //check for optional inputs if (homepage && homepage !== "") { tstore.package.websiteUrl = homepage; } else { - tstore.package.websiteUrl = `${Deno.env.get("GITHUB_SERVER_URL")}/${Deno.env.get("GITHUB_REPOSITORY")}`; + tstore.package.websiteUrl = `${Deno.env.get( + "GITHUB_SERVER_URL" + )}/${Deno.env.get("GITHUB_REPOSITORY")}`; } -if (nsfw && nsfw === "true" ) { - tstore.package.containsNsfwContent = true +if (nsfw && nsfw === "true") { + tstore.package.containsNsfwContent = true; } if (categories && categories !== "") { console.log(`::debug::Parsing categories: ${categories}`); - tstore.publish.categories[community] = categories.split(',') - .filter(e => e) //only keep truthy elements - .map(e=> e.toLowerCase().trim()); + tstore.publish.categories[community] = categories + .split(",") + .filter((e) => e) //only keep truthy elements + .map((e) => e.toLowerCase().trim()); } if (deps && deps !== "") { + console.log("::debug::Parsing dependencies: ", deps.split(" ")); const p = {}; - for (let d of deps.split(' ')) { - if(!d) + for (let d of deps.split(" ")) { + if (!d) { + console.log("::warn::Empty dependency", d); continue; - if (!d.includes('@')) { - console.log("Malformed dependency at ", d); - Deno.exit(-1); } - - const parts = d.split('@'); - p[parts[0]] = parts[1]; + + const parts = d.match(re); + if (parts) { + console.log("::debug::Parts:", parts); + p[parts[1]] = parts[2]; + } else { + console.log("::error::Malformed dependency at ", d); + Deno.exit(1); + } } - - console.log(p); + + console.log("::debug:: Built depencendies:", p); tstore.package.dependencies = p; } - //write config file back to disk Deno.writeTextFile("./thunderstore.toml", TOML.stringify(tstore)); diff --git a/entrypoint.sh b/entrypoint.sh index 643cf42..0198178 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -47,7 +47,7 @@ function configure(){ echo "Init tcli config" tcli init --package-name ${TS_NAME} --package-namespace ${TS_NAMESPACE} --package-version ${TS_VERSION#v} - echo $(deno run --allow-net --allow-env --allow-read --allow-write cfg_edit.js) + deno run --allow-net --allow-env --allow-read --allow-write cfg_edit.js echo "Done config edit" echo