name: Publish package to GitHub Packages
on:
  push:
  pull_request:

jobs:
  test:
    runs-on: windows-latest
    env:
      JDK_JAVA_OPTIONS: "--add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.io=ALL-UNNAMED"
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-java@v2
        with:
          java-version: "17"
          distribution: "adopt"
      - name: Validate
        run: |
          cd code
          mvn --batch-mode validate
      - name: Test
        run: |
          cd code
          mvn --batch-mode test
  publish:
    if: github.ref == 'refs/heads/master' && github.repository_owner == 'Codeforces'
    needs: test
    runs-on: windows-latest
    permissions:
      contents: read
      packages: write
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-java@v2
        with:
          java-version: "17"
          distribution: "adopt"
      - name: Validate
        run: |
          cd code
          mvn --batch-mode validate
      - name: Publish
        run: |
          cd code
          mvn --batch-mode deploy -DskipTests
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

name: Publish package to GitHub Packages
on:
  push:
  pull_request:

jobs:
  test:
    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-latest, windows-latest, macos-latest]
        java-version: [8, 11, 17]
    runs-on: ${{ matrix.os }}
    env:
      JDK_JAVA_OPTIONS: "--add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.io=ALL-UNNAMED"
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-java@v2
        with:
          java-version: ${{ matrix.java-version }}
          distribution: "adopt"
      - name: Validate
        run: |
          cd code
          mvn --batch-mode validate
      - name: Test
        run: |
          cd code
          mvn --batch-mode test
  publish:
    if: github.ref == 'refs/heads/master' && github.repository_owner == 'Codeforces'
    needs: test
    runs-on: windows-latest
    permissions:
      contents: read
      packages: write
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-java@v2
        with:
          java-version: "17"
          distribution: "adopt"
      - name: Validate
        run: |
          cd code
          mvn --batch-mode validate
      - name: Publish
        run: |
          cd code
          mvn --batch-mode deploy -DskipTests
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Test on all systems, several java versions
Test on all systems, several java versions
