7ee7cb6d93
cargo-apk 0.10 and its fork cargo-apk2 both failed to discover the installed Android platform in this Gitea runner, despite ANDROID_HOME, platforms;android-34, build-tools, and NDK all being present, readable, and pointed at correctly. We never isolated whether the bug is in the shared ndk-build crate's discovery logic or in the runner's env-var propagation through cargo subcommand exec, so this commit stops fighting either tool and assembles the APK from explicit toolchain steps instead: cargo ndk -> per-ABI .so files aapt2 compile/link -> manifest + resources -> base APK zip -> bundle native libs into lib/<abi>/ zipalign -> 4-byte alignment apksigner -> v2/v3 signing (debug keystore for CI, real for release) The pipeline lives in scripts/build_android_apk.sh so it's reproducible locally (same env vars, same commands). AndroidManifest.xml is now checked in under solitaire_app/android/ and mirrors what cargo-apk would have generated from [package.metadata.android] — keep them in sync if either is changed. Local `cargo apk build` still works on developer machines where cargo-apk is happy; CI just stops depending on it. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
123 lines
4.7 KiB
YAML
123 lines
4.7 KiB
YAML
name: Android Build
|
|
|
|
on:
|
|
push:
|
|
branches: [master]
|
|
# Rebuild whenever app/engine/asset code changes.
|
|
# Skip server-only, deploy, and doc changes.
|
|
paths-ignore:
|
|
- 'deploy/**'
|
|
- 'argocd/**'
|
|
- 'solitaire_server/**'
|
|
- '**.md'
|
|
|
|
env:
|
|
ANDROID_SDK: /opt/android-sdk
|
|
NDK_VERSION: "25.2.9519653"
|
|
BUILD_TOOLS_VERSION: "34.0.0"
|
|
PLATFORM: "android-34"
|
|
|
|
jobs:
|
|
build-apk:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set short SHA
|
|
id: meta
|
|
run: echo "sha=${GITHUB_SHA::8}" >> "$GITHUB_OUTPUT"
|
|
|
|
# ── System dependencies ────────────────────────────────────────────
|
|
- name: Install system dependencies
|
|
run: |
|
|
sudo apt-get update -y
|
|
sudo apt-get install -y openjdk-17-jdk-headless unzip zip
|
|
|
|
# ── Android SDK (shared cache key with release workflow) ──────────
|
|
- name: Cache Android SDK
|
|
uses: actions/cache@v4
|
|
id: sdk-cache
|
|
with:
|
|
path: ${{ env.ANDROID_SDK }}
|
|
key: v2-android-sdk-ndk${{ env.NDK_VERSION }}-bt${{ env.BUILD_TOOLS_VERSION }}
|
|
|
|
- name: Install Android SDK + NDK
|
|
if: steps.sdk-cache.outputs.cache-hit != 'true'
|
|
run: |
|
|
sudo mkdir -p ${{ env.ANDROID_SDK }}/cmdline-tools
|
|
curl -sL \
|
|
"https://dl.google.com/android/repository/commandlinetools-linux-11076708_latest.zip" \
|
|
-o /tmp/cmdtools.zip
|
|
unzip -q /tmp/cmdtools.zip -d /tmp/cmdtools
|
|
sudo mv /tmp/cmdtools/cmdline-tools ${{ env.ANDROID_SDK }}/cmdline-tools/latest
|
|
yes | sudo ${{ env.ANDROID_SDK }}/cmdline-tools/latest/bin/sdkmanager \
|
|
--sdk_root=${{ env.ANDROID_SDK }} --licenses > /dev/null 2>&1 || true
|
|
sudo ${{ env.ANDROID_SDK }}/cmdline-tools/latest/bin/sdkmanager \
|
|
--sdk_root=${{ env.ANDROID_SDK }} \
|
|
"build-tools;${{ env.BUILD_TOOLS_VERSION }}" \
|
|
"platforms;${{ env.PLATFORM }}" \
|
|
"ndk;${{ env.NDK_VERSION }}"
|
|
|
|
# ── Rust toolchain ─────────────────────────────────────────────────
|
|
- name: Install Rust stable
|
|
run: |
|
|
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs \
|
|
| sh -s -- -y --default-toolchain stable --no-modify-path
|
|
echo "$HOME/.cargo/bin" >> "$GITHUB_PATH"
|
|
|
|
- name: Add Android cross-compilation targets
|
|
run: |
|
|
rustup target add \
|
|
aarch64-linux-android \
|
|
armv7-linux-androideabi \
|
|
x86_64-linux-android
|
|
|
|
# ── Cargo caches ───────────────────────────────────────────────────
|
|
- name: Cache Cargo registry
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: |
|
|
~/.cargo/registry/index
|
|
~/.cargo/registry/cache
|
|
~/.cargo/git/db
|
|
key: cargo-registry-${{ hashFiles('**/Cargo.lock') }}
|
|
restore-keys: cargo-registry-
|
|
|
|
- name: Cache cargo-ndk binary
|
|
uses: actions/cache@v4
|
|
id: ndk-tool-cache
|
|
with:
|
|
path: ~/.cargo/bin/cargo-ndk
|
|
key: cargo-ndk-${{ runner.os }}-stable
|
|
|
|
- name: Cache build artifacts
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: target
|
|
key: android-target-${{ hashFiles('**/Cargo.lock') }}-${{ github.sha }}
|
|
restore-keys: android-target-${{ hashFiles('**/Cargo.lock') }}-
|
|
|
|
- name: Install cargo-ndk
|
|
if: steps.ndk-tool-cache.outputs.cache-hit != 'true'
|
|
run: cargo install cargo-ndk --locked
|
|
|
|
# ── Build APK ──────────────────────────────────────────────────────
|
|
- name: Build debug APK
|
|
env:
|
|
ANDROID_HOME: ${{ env.ANDROID_SDK }}
|
|
ANDROID_NDK_HOME: ${{ env.ANDROID_SDK }}/ndk/${{ env.NDK_VERSION }}
|
|
BUILD_TOOLS_VERSION: ${{ env.BUILD_TOOLS_VERSION }}
|
|
PLATFORM: ${{ env.PLATFORM }}
|
|
PROFILE: debug
|
|
run: ./scripts/build_android_apk.sh
|
|
|
|
# ── Artifact ───────────────────────────────────────────────────────
|
|
- name: Upload APK
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: solitaire-quest-debug-${{ steps.meta.outputs.sha }}
|
|
path: target/debug/apk/solitaire-quest.apk
|
|
retention-days: 30
|