name: CI

on:
  push:
    branches:
      - main
  pull_request:
    branches:
      - main

jobs:
  build:
    runs-on: ubuntu-24.04
    permissions:
      contents: read
      pull-requests: write
      issues: write

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

      - name: Setup Development Environment
        uses: jdx/mise-action@v3

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

      - name: Check ktlint
        run: ./gradlew ktlintCheck --no-daemon

      - name: Build with shadowJar
        run: ./gradlew :platform-paper:shadowJar --parallel --no-daemon

      - name: Upload build artifact
        uses: actions/upload-artifact@v6
        if: success()
        with:
          name: LunaticChat-${{ github.sha }}
          path: platform-paper/build/libs/*-all.jar
          retention-days: 7
