name: Release for 1.21.1

on:
  push:
    branches: [ '1.21.1' ]
  workflow_dispatch:

jobs:
  release:
    name: Publish release JAR for Ex Deorum
    runs-on: ubuntu-latest
    if: "startsWith(github.event.head_commit.message, '[Release]')"
    steps:
      - name: Checkout code
        uses: actions/checkout@v4

      - name: Setup Java
        uses: actions/setup-java@v4
        with:
          distribution: 'microsoft'
          java-version: '21'

      - name: Setup Gradle
        uses: gradle/actions/setup-gradle@v4

      - name: Upload to CurseForge
        run: ./gradlew curseforge
        env:
          CURSEFORGE_TOKEN: ${{ secrets.CURSEFORGE_TOKEN }}

      - name: Upload to Modrinth
        run: ./gradlew modrinth
        env:
          MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }}