name: Build

on: [push, pull_request]

jobs:
  mac:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2.1.0
      - name: Set up JDK
        uses: actions/setup-java@v1.3.0
        with:
          java-version: 8
          server-id: ossrh
          server-username: SONATYPE_USER
          server-password: SONATYPE_PW

      - name: Build
        run: mvn -B package

      - name: Attach jars
        uses: actions/upload-artifact@v2
        with:
          name: jar
          path: target/otr4j-*

      - name: Extract Branch Name
        run: echo "::set-env name=BRANCH::$(echo ${GITHUB_REF#refs/heads/})"

      - name: Release to Maven Central
        if: env.BRANCH == 'master'
        env:
          SONATYPE_USER: ${{ secrets.SONATYPE_USER }}
          SONATYPE_PW: ${{ secrets.SONATYPE_PW }}
        run: |
          cat <(echo -e "${{ secrets.GPG_KEY }}") | gpg --batch --import
          gpg --list-secret-keys --keyid-format LONG
          mvn \
            --no-transfer-progress \
            --batch-mode \
            -Dgpg.passphrase="${{ secrets.GPG_PW }}" \
            -DperformRelease=true \
            deploy

name: Java CI with Maven

on: [push, pull_request]

jobs:
  build:
    runs-on: ubuntu-latest

    strategy:
      matrix:
        java: [ '1.8', '11' ]

    name: ${{ matrix.java }}
    steps:
      - uses: actions/checkout@v2.1.0
      - name: Set up JDK ${{ matrix.java }}
        uses: actions/setup-java@v1.3.0
        with:
          java-version: ${{ matrix.java }}
          server-id: ossrh
          server-username: SONATYPE_USER
          server-password: SONATYPE_PW

      - name: Build
        run: mvn -B verify javadoc:javadoc

      - name: Attach jars
        uses: actions/upload-artifact@v2
        with:
          name: jar
          path: target/otr4j-*

      - name: Extract Branch Name
        run: echo "::set-env name=BRANCH::$(echo ${GITHUB_REF#refs/heads/})"

      - name: Release to Maven Central
        if: env.BRANCH == 'master'
        env:
          SONATYPE_USER: ${{ secrets.SONATYPE_USER }}
          SONATYPE_PW: ${{ secrets.SONATYPE_PW }}
        run: |
          cat <(echo -e "${{ secrets.GPG_KEY }}") | gpg --batch --import
          gpg --list-secret-keys --keyid-format LONG
          mvn \
            --no-transfer-progress \
            --batch-mode \
            -Dgpg.passphrase="${{ secrets.GPG_PW }}" \
            -DperformRelease=true \
            deploy

Build for Java 8 and 11
Build for Java 8 and 11
