name: publish-android

on:
#  release:
#    types: [published]

  workflow_dispatch:
    inputs:
      publish:
        description: 'Publish package (y/n)'
        default: 'n'

jobs:
  publish:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v4
    - uses: actions/setup-java@v4
      with:
        distribution: 'temurin'
        java-version: '17'
#      working-directory: wrappers/android
#      run: ./gradlew versionDisplay

    - name: Build Library
      working-directory: wrappers/android
      run: ./gradlew assembleRelease

    - name: Publish Library
      if: ${{ github.event.inputs.publish == 'y' }}
      working-directory: wrappers/android
      env:
        ORG_GRADLE_PROJECT_signingKey: ${{ secrets.OSSRH_GPG_SECRET_KEY }}
        ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }}
        ORG_GRADLE_PROJECT_ossrhUsername: ${{ secrets.OSSRH_USERNAME }}
        ORG_GRADLE_PROJECT_ossrhPassword: ${{ secrets.OSSRH_PASSWORD }}
      run: ./gradlew publishReleasePublicationToSonatypeRepository
