diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index 1cc4339..f11ad56 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -61,4 +61,13 @@ jobs: path: | ${{ steps.calculate_artifact_names.outputs.fabric }} ${{ steps.calculate_artifact_names.outputs.fabric }}.asc - + - name: Upload Releases + if: startsWith(github.ref, 'refs/tags/release-') + env: + GIT_REF: ${{ github.ref }} + FABRIC_JAR: ${{ steps.calculate_artifact_names.outputs.fabric }} + FORGE_JAR: ${{ steps.calculate_artifact_names.outputs.forge }} + CURSEFORGE_TOKEN: ${{ secrets.WILLIEWILLUS_CURSEFORGE_TOKEN }} + MODRINTH_TOKEN: ${{ secrets.WILLIEWILLUS_MODRINTH_TOKEN }} + run: | + scripts/upload_releases.sh diff --git a/scripts/upload_releases.sh b/scripts/upload_releases.sh new file mode 100755 index 0000000..fadc613 --- /dev/null +++ b/scripts/upload_releases.sh @@ -0,0 +1,173 @@ +#!/usr/bin/env bash +set -euo pipefail + +# Remove 'refs/tags/' from front +TAGNAME="${GIT_REF/#refs\/tags\/}" + +# Remove 'release-' from front +VERSION="${TAGNAME/#release-}" +MC_VERSION=$(echo "${VERSION}" | cut -d '-' -f 1) + +function release_github() { + echo >&2 'Creating GitHub Release' + local GH_RELEASE_RESPONSE + GH_RELEASE_RESPONSE="$(gh api \ + --method POST \ + -H "Accept: application/vnd.github+json" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + /repos/VazkiiMods/Neat/releases \ + -F prerelease=true \ + -f tag_name="${TAGNAME}")" + GH_RELEASE_PAGE=$(echo "$GH_RELEASE_RESPONSE" | jq -r .html_url) + + echo >&2 'Uploading Fabric Jar and Signature to GitHub' + gh release upload "${TAGNAME}" "${FABRIC_JAR}#Fabric Jar" + gh release upload "${TAGNAME}" "${FABRIC_JAR}.asc#Fabric Signature" + echo >&2 'Uploading Forge Jar and Signature to GitHub' + gh release upload "${TAGNAME}" "${FORGE_JAR}#Forge Jar" + gh release upload "${TAGNAME}" "${FORGE_JAR}.asc#Forge Signature" +} + +function release_modrinth() { + echo >&2 'Uploading Fabric Jar to Modrinth' + local MODRINTH_FABRIC_SPEC + MODRINTH_FABRIC_SPEC=$(cat <&2 'Uploading Forge Jar to Modrinth' + local MODRINTH_FORGE_SPEC + MODRINTH_FORGE_SPEC=$(cat <&2 'Uploading Fabric Jar to CurseForge' + local CURSEFORGE_FABRIC_SPEC + CURSEFORGE_FABRIC_SPEC=$(cat <&2 'Uploading Forge Jar to CurseForge' + local CURSEFORGE_FORGE_SPEC + CURSEFORGE_FORGE_SPEC=$(cat <