name: Java Build

on:
  push:
    branches: [ "master" ]
  pull_request:
    branches: [ "master" ]

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout repository
        uses: actions/checkout@v4

      - name: Set up JDK 17
        uses: actions/setup-java@v4
        with:
          java-version: '17'
          distribution: 'temurin'

      - name: Compile sources
        run: javac -d out $(find src -name "*.java")

      - name: Create JAR
        run: |
          mkdir -p target
          jar --create --file target/app.jar --main-class Main -C out .

      - name: Upload JAR artifact
        uses: actions/upload-artifact@v4
        with:
          name: app
          path: target/app.jar