name: Maven Release


on:
  release:
    types: [published]

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-java@v3
        with:
          distribution: zulu
          java-version: 8
          server-id: ossrh
          server-username: MAVEN_USERNAME
          server-password: MAVEN_PASSWORD
      - name: Import GPG Key
        run: |
          mkdir -p ~/.gnupg/
          echo "$MAVEN_SIGNING_KEY" | gpg --import -
        env:
          MAVEN_SIGNING_KEY: ${{ secrets.MAVEN_SIGNING_KEY }}
      - name: Maven Deploy
        run: mvn -B -V deploy -Ddeploy
        env:
          MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
          MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
      - name: Generate javadocs
        run: mvn compile javadoc:aggregate
      - name: Publish javadocs
        uses: JamesIves/github-pages-deploy-action@v4.3.3
        with:
          branch: gh-pages
          folder: target/site/apidocs
