android-apk #21
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: android-apk | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| features: | |
| description: "Cargo features for rockbox-expo cdylib (space-separated)" | |
| default: "embedded-daemon" | |
| required: false | |
| type: string | |
| architectures: | |
| description: "React Native architectures to include in the APK" | |
| default: "arm64-v8a" | |
| required: false | |
| type: string | |
| env: | |
| CARGO_TERM_COLOR: always | |
| RUSTFLAGS: -A warnings | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| submodules: true | |
| - uses: actions/setup-java@v4 | |
| with: | |
| java-version: "17" | |
| distribution: temurin | |
| - name: Install system dependencies | |
| run: | | |
| sudo apt-get update -qq | |
| sudo apt-get install -y --no-install-recommends \ | |
| protobuf-compiler cmake ninja-build | |
| - name: Set up Android SDK and NDK | |
| run: | | |
| echo "ANDROID_SDK_ROOT=$ANDROID_SDK_ROOT" >> $GITHUB_ENV | |
| echo "ANDROID_NDK_HOME=$ANDROID_NDK_LATEST_HOME" >> $GITHUB_ENV | |
| echo "ANDROID_NDK_ROOT=$ANDROID_NDK_LATEST_HOME" >> $GITHUB_ENV | |
| - uses: actions-rust-lang/setup-rust-toolchain@v1 | |
| - name: Add Android Rust targets | |
| run: rustup target add aarch64-linux-android armv7-linux-androideabi x86_64-linux-android | |
| - name: Install cargo-ndk | |
| run: cargo install cargo-ndk --locked | |
| - uses: oven-sh/setup-bun@v2 | |
| - uses: denoland/setup-deno@v2 | |
| - name: Build Web UI | |
| run: | | |
| cd webui/rockbox | |
| deno install | |
| deno run build | |
| deno clean | |
| rm -rf node_modules | |
| - name: Cache Cargo registry and git | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.cargo/registry | |
| ~/.cargo/git | |
| key: android-cargo-${{ hashFiles('**/Cargo.lock') }} | |
| restore-keys: android-cargo- | |
| - name: Cache Cargo build artifacts | |
| uses: actions/cache@v4 | |
| with: | |
| path: target/ | |
| key: android-target-${{ inputs.features }}-${{ hashFiles('**/Cargo.lock') }} | |
| restore-keys: | | |
| android-target-${{ inputs.features }}- | |
| android-target- | |
| - name: Cache Android firmware build | |
| uses: actions/cache@v4 | |
| with: | |
| path: build-android-arm64/ | |
| key: android-firmware-${{ hashFiles('firmware/**', 'apps/**', 'lib/**', 'tools/configure') }} | |
| restore-keys: android-firmware- | |
| - name: Build Android firmware (C static libs) | |
| run: | | |
| mkdir -p build-android-arm64 | |
| rm -f build-android-arm64/make.dep | |
| cd build-android-arm64 | |
| printf "205\n" | \ | |
| ANDROID_TARGET_ABI=arm64-v8a ANDROID_API_LEVEL=26 \ | |
| ARG_LCDWIDTH=320 ARG_LCDHEIGHT=480 \ | |
| ../tools/configure | |
| make -j$(nproc) lib | |
| - name: Install Expo dependencies | |
| working-directory: expo | |
| run: bun install | |
| - name: Generate Android project (expo prebuild) | |
| working-directory: expo | |
| run: bunx expo prebuild --platform android --no-install | |
| - name: Write local.properties | |
| run: echo "sdk.dir=$ANDROID_SDK_ROOT" > expo/android/local.properties | |
| - name: Build Rust cdylib (rockbox-expo) | |
| env: | |
| FEATURES: ${{ inputs.features }} | |
| PROFILE: release | |
| run: bash expo/modules/rockbox-rpc/scripts/build-android.sh | |
| - name: Show built .so files | |
| run: find expo/modules/rockbox-rpc/android/src/main/jniLibs -name '*.so' -exec ls -lh {} \; | |
| - uses: gradle/actions/setup-gradle@v4 | |
| - name: Build APK | |
| working-directory: expo/android | |
| run: | | |
| ./gradlew assembleRelease \ | |
| -PreactNativeArchitectures=${{ inputs.architectures }} \ | |
| --no-daemon \ | |
| --stacktrace | |
| - name: Show APK | |
| run: | | |
| find expo/android/app/build/outputs/apk -name '*.apk' -exec ls -lh {} \; | |
| - name: Upload APK artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: rockbox-android-apk-${{ github.run_number }} | |
| path: expo/android/app/build/outputs/apk/release/app-release.apk | |
| retention-days: 30 | |
| if-no-files-found: error |