name: Deploy
on:
  workflow_call:
    inputs:
      branch:
        required: true
        type: string
      jdk:
        default: 8
        type: string
jobs:
  Deploy:
    name: Deploy to OSSRH
    runs-on: ubuntu-latest
    env:
      VERTX_NEXUS_USERNAME: ${{ secrets.VERTX_NEXUS_USERNAME }}
      VERTX_NEXUS_PASSWORD: ${{ secrets.VERTX_NEXUS_PASSWORD }}
    steps:
      - name: Checkout
        uses: actions/checkout@v2
        with:
          ref: ${{ inputs.branch }}
      - name: Install JDK
        uses: actions/setup-java@v2
        with:
          java-version: ${{ inputs.jdk }}
          distribution: temurin
      - name: Get project version
        run: echo "PROJECT_VERSION=$(mvn org.apache.maven.plugins:maven-help-plugin:evaluate -Dexpression=project.version -q -DforceStdout | grep -v '\[')" >> $GITHUB_ENV
      - name: Maven deploy
        if: ${{ endsWith(env.PROJECT_VERSION, '-SNAPSHOT') }}
        run: mvn deploy -s .github/maven-cd-settings.xml -DskipTests -B
