name: Maven build with tests
on: [ push, pull_request ]
jobs:
  build:
    name: JDK ${{ matrix.java }}
    runs-on: ubuntu-latest
    strategy:
      matrix:
        java: [ '8', '11' ]
    steps:
      - uses: actions/checkout@v2
      - name: Set up JDK ${{ matrix.java }}
        uses: actions/setup-java@v1
        with:
          java-version: ${{ matrix.java }}
      - uses: actions/cache@v1
        with:
          path: ~/.m2/repository
          key: ${{ runner.os }}-maven-jdk${{ matrix.java }}-${{ hashFiles('**/pom.xml') }}
          restore-keys: |
            ${{ runner.os }}-maven-jdk${{ matrix.java }}-
      - name: Build with Maven
        run: mvn -B clean install
  release:
    name: Release
    needs: [build]
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v2
        with:
          fetch-depth: 0
      - name: Setup Node.js
        uses: actions/setup-node@v1
        with:
          node-version: 14
      - name: Release
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        run: npm install && npx semantic-release

