on:
  push:
    # TODO: remove versioning branch once everything works
    branches: [main,versioning]
    tags:
      - '[0-9]+.[0-9]+.[0-9]+'
name: Flatpak
jobs:
  flatpak:
    name: Flatpak
    runs-on: ubuntu-latest
    container:
      image: ghcr.io/flathub-infra/flatpak-github-actions:gnome-48
      options: --privileged
    steps:
      - uses: actions/checkout@v4
      - name: Set up JDK 21
        uses: actions/setup-java@v4
        with:
          java-version: 21
          distribution: 'temurin'
      - name: Cache Gradle packages
        uses: actions/cache@v4
        with:
          path: ~/.gradle/caches
          key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
          restore-keys: ${{ runner.os }}-gradle
      - name: Build Release Uber JAR
        run: ./gradlew packageReleaseUberJarForCurrentOS
      - uses: flatpak/flatpak-github-actions/flatpak-builder@v6
        with:
          bundle: YAEP.flatpak
          manifest-path: ./flatpak/ch.dissem.YAEP.yml
          cache-key: flatpak-builder-${{ github.sha }}
