name: Release new JAR to GitHub Packages
on:
  push:
    tags:
      - "v*"

env:
  GITHUB_USERNAME: AntonOellerer

jobs:
  gradle-publish:
    runs-on: ubuntu-latest
    env:
      GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-java@v3.13.0
        with:
          java-version: 17
          distribution: 'zulu'
      - uses: gradle/gradle-build-action@v2
        with:
          arguments: build -x test -x check publish
      - uses: "marvinpinto/action-automatic-releases@latest"
        with:
          repo_token: ${{ secrets.GITHUB_TOKEN }}
          prerelease: false
          files: |
            build/libs/*.jar
            LICENSE