eba1f66b45
Replace shell variable $ANDROID_HOME references in run blocks with
${{ env.ANDROID_SDK }} template expressions. Gitea runner v1 may not
override Docker-image-baked ENV vars via docker exec; template expansion
happens at workflow compilation time, so the literal path is hardcoded
into the script before the shell runs it.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
119 lines
4.6 KiB
YAML
119 lines
4.6 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"
|
|
|
|
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
|
|
|
|
# ── 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;android-34" \
|
|
"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-apk binary
|
|
uses: actions/cache@v4
|
|
id: apk-tool-cache
|
|
with:
|
|
path: ~/.cargo/bin/cargo-apk
|
|
key: cargo-apk-${{ 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') }}-
|
|
|
|
# ── Build ──────────────────────────────────────────────────────────
|
|
- name: Install cargo-apk
|
|
if: steps.apk-tool-cache.outputs.cache-hit != 'true'
|
|
run: cargo install cargo-apk --locked
|
|
|
|
- name: Build debug APK
|
|
run: |
|
|
export ANDROID_HOME=${{ env.ANDROID_SDK }}
|
|
export ANDROID_NDK_HOME=${{ env.ANDROID_SDK }}/ndk/${{ env.NDK_VERSION }}
|
|
cargo apk build --package solitaire_app --lib
|
|
|
|
# ── 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
|