name: Build

on:
  push:
    branches-ignore:
      - master
  pull_request:

jobs:
  build:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        java: [ 8, 11, 15 ]

    steps:
      - uses: actions/checkout@v2

      - name: Set up JDK ${{ matrix.java }}
        uses: actions/setup-java@v1
        with:
          java-version: ${{ matrix.java }}

      - name: Maven Build
        run: mvn --batch-mode package -Pbuild-extras -X
        env:
          JAVA_TOOL_OPTIONS: -XX:+UseG1GC -Xss4m

      - name: "Upload Artifact: Glowstone Server"
        uses: actions/upload-artifact@v2
        with:
          name: Glowstone Server (Java ${{ matrix.java }})
          path: target/glowstone.jar

      - name: "Upload Artifact: JavaDoc JAR"
        uses: actions/upload-artifact@v2
        with:
          name: JavaDoc JAR (Java ${{ matrix.java }})
          path: target/glowstone-javadoc.jar

      - name: "Upload Artifact: Sources JAR"
        uses: actions/upload-artifact@v2
        with:
          name: Sources JAR (Java ${{ matrix.java }})
          path: target/glowstone-sources.jar
