name: Native publish MXNet

on:
  workflow_dispatch:
    inputs:
        mode:
          description: 'staging/snapshot, default is snapshot'
          required: true
          default: 'snapshot'

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v4
      - name: Set up JDK 17
        uses: actions/setup-java@v4
        with:
          distribution: 'corretto'
          java-version: 17
      # Enable gradle cache: https://github.com/actions/cache/blob/master/examples.md#java---gradle
      - uses: actions/cache@v4
        with:
          path: ~/.gradle/caches
          key: ${{ runner.os }}-gradle-${{ hashFiles('*/build.gradle.kts', 'engines/**/build.gradle.kts', 'extensions/**/build.gradle.kts') }}
          restore-keys: |
            ${{ runner.os }}-gradle-
      - name: Download native binaries
        run: ./gradlew :engines:mxnet:native:dMNL
      - name: Publish to snapshot/staging repository
        working-directory: engines/mxnet/native
        run: ./gradlew publish -P${{ github.event.inputs.mode }}
        env:
          ORG_GRADLE_PROJECT_signingKey: ${{ secrets.ORG_GRADLE_PROJECT_signingKey }}
          ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.ORG_GRADLE_PROJECT_signingPassword }}
          ORG_GRADLE_PROJECT_ossrhUsername: ${{ secrets.ORG_GRADLE_PROJECT_ossrhUsername }}
          ORG_GRADLE_PROJECT_ossrhPassword: ${{ secrets.ORG_GRADLE_PROJECT_ossrhPassword }}
