ci: add workflow to build and release native library #1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build Native Library | |
| on: | |
| push: | |
| branches: [ main ] | |
| workflow_dispatch: | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up JDK 21 | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: temurin | |
| java-version: 21 | |
| - name: Set up Android SDK & NDK | |
| uses: android-actions/setup-android@v3 | |
| - name: Install NDK | |
| run: sdkmanager "ndk;26.1.10909125" | |
| - name: Build for all architectures | |
| run: | | |
| NDK=$ANDROID_SDK_ROOT/ndk/26.1.10909125 | |
| for ABI in arm64-v8a armeabi-v7a x86_64 x86; do | |
| echo "Building for $ABI..." | |
| mkdir -p build/$ABI | |
| cd build/$ABI | |
| cmake ../.. \ | |
| -DCMAKE_TOOLCHAIN_FILE=$NDK/build/cmake/android.toolchain.cmake \ | |
| -DANDROID_ABI=$ABI \ | |
| -DANDROID_PLATFORM=android-24 \ | |
| -DCMAKE_BUILD_TYPE=Release | |
| cmake --build . --parallel | |
| cd ../.. | |
| done | |
| - name: Package artifacts | |
| run: | | |
| mkdir -p dist/jniLibs | |
| for ABI in arm64-v8a armeabi-v7a x86_64 x86; do | |
| mkdir -p dist/jniLibs/$ABI | |
| cp build/$ABI/libcoverart.so dist/jniLibs/$ABI/ | |
| done | |
| cd dist && zip -r ../libcoverart-jniLibs.zip jniLibs | |
| - name: Upload build artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: libcoverart-jniLibs | |
| path: dist/jniLibs |