name: Android NDK Build

on:
  pull_request:
    branches: [ dev, release, actionsTest ]
  push:
    branches: [ actionsTest, '*ndk*' ]

permissions: read-all

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # tag=v4.1.1

    - name: Set up JDK 17
      uses: actions/setup-java@3a4f6e1af504cf6a31855fa899c6aa5355ba6c12 # v4.7.0
      with:
        java-version: '17'
        distribution: 'temurin'

    - name: Setup Android SDK
      uses: android-actions/setup-android@9fc6c4e9069bf8d3d10b2204b1fb8f6ef7065407 # v3.2.2

    - name: Install Android NDK
      run: |
        sdkmanager --install "ndk;27.0.12077973"
        echo "ANDROID_NDK_HOME=$ANDROID_SDK_ROOT/ndk/27.0.12077973" >> $GITHUB_ENV

    - name: Build with NDK
      run: |
        export PATH=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin:$PATH
        make CC=aarch64-linux-android21-clang \
             AR=llvm-ar \
             RANLIB=llvm-ranlib \
             STRIP=llvm-strip

