diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml new file mode 100644 index 0000000..560ad7e --- /dev/null +++ b/.gitea/workflows/release.yml @@ -0,0 +1,66 @@ +name: Release + +# Publishing a release builds every Minecraft version and attaches the mod jars +# to it. mod_version in gradle.properties is the source of truth: the release +# tag must match it (a leading "v" is allowed), so bump mod_version in a PR +# before tagging the release. +on: + release: + types: [published] + +permissions: + contents: write + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + submodules: true + + - name: Check tag matches mod_version + env: + TAG: ${{ github.event.release.tag_name }} + run: | + MOD_VERSION="$(sed -n 's/^mod_version=//p' gradle.properties | tr -d '[:space:]')" + if [ "${TAG#v}" != "$MOD_VERSION" ]; then + echo "::error::Release tag '$TAG' doesn't match mod_version '$MOD_VERSION' in gradle.properties. Bump mod_version to '${TAG#v}' on the release branch, or tag the release '$MOD_VERSION'." >&2 + exit 1 + fi + echo "Building Saturn Client $MOD_VERSION" + + - name: Set up Java 21 + uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: 21 + cache: gradle + + - name: Build all versions + run: | + chmod +x gradlew + # buildAll remaps every versions/* project in parallel into build/allJars. + ./gradlew buildAll --no-daemon --stacktrace + + - name: Upload jars to the release + env: + TOKEN: ${{ secrets.GITEA_TOKEN }} + ASSETS_URL: ${{ github.server_url }}/api/v1/repos/${{ github.repository }}/releases/${{ github.event.release.id }}/assets + run: | + shopt -s nullglob + jars=(build/allJars/*.jar) + if [ ${#jars[@]} -eq 0 ]; then + echo "No jars found in build/allJars" >&2 + exit 1 + fi + + for jar in "${jars[@]}"; do + echo "Uploading $(basename "$jar")" + curl --fail-with-body -sS -X POST \ + -H "Authorization: token $TOKEN" \ + -F "attachment=@$jar" \ + "$ASSETS_URL" + echo + done diff --git a/gradle.properties b/gradle.properties index 6598a82..b21030b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,4 +4,4 @@ org.gradle.parallel=true # IntelliJ IDEA is not yet fully compatible with configuration cache, see: https://github.com/FabricMC/fabric-loom/issues/1349 org.gradle.configuration-cache=false -mod_version=0.1.0-beta3 +mod_version=0.1.1-beta