Skip to content

Add files via upload #60

Add files via upload

Add files via upload #60

Workflow file for this run

# Builds a debug APK of the standalone Fio Player with buildozer
# (python-for-android) and uploads it as a downloadable artifact.
#
# Trigger it from the GitHub UI: Actions -> "Android Player Build" -> Run
# workflow. It also runs automatically when files under player/ change.
#
# The FIRST run is slow (~25-45 min): buildozer downloads the Android SDK/NDK
# and cross-compiles CPython + every native dependency. Later runs reuse the
# cached ~/.buildozer, so they are much faster.
name: Android Player Build
on:
workflow_dispatch: # manual "Run workflow" button
push:
paths:
- 'player/**'
- 'engine/**'
- 'main.py'
- '.github/workflows/android-build.yml'
jobs:
build-apk:
# Ubuntu 22.04: python-for-android's toolchain (and packages like
# libtinfo5 / libncurses5-dev) is reliable here. 24.04 ("noble", what
# ubuntu-latest now is) dropped libtinfo5, which the Android NDK needs.
runs-on: ubuntu-22.04
timeout-minutes: 90
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
# System packages python-for-android needs to bootstrap the toolchain.
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
git zip unzip openjdk-17-jdk autoconf libtool pkg-config \
zlib1g-dev libncurses-dev cmake libffi-dev libssl-dev \
build-essential ccache wget
# The Android SDK build-tools link against libtinfo.so.5. It ships in
# the repos on 22.04 but was dropped in 24.04 (noble); fetch the deb
# directly if apt can't find it, so this works on any runner image.
if ! sudo apt-get install -y libtinfo5 2>/dev/null; then
echo "libtinfo5 not in apt; fetching the package directly..."
for url in \
http://mirrors.kernel.org/ubuntu/pool/universe/n/ncurses/libtinfo5_6.3-2ubuntu0.1_amd64.deb \
http://security.ubuntu.com/ubuntu/pool/universe/n/ncurses/libtinfo5_6.3-2ubuntu0.1_amd64.deb \
http://archive.ubuntu.com/ubuntu/pool/universe/n/ncurses/libtinfo5_6.3-2_amd64.deb ; do
if wget -q "$url" -O /tmp/libtinfo5.deb; then break; fi
done
sudo dpkg -i /tmp/libtinfo5.deb || sudo apt-get -f install -y
fi
- name: Install buildozer
run: |
python -m pip install --upgrade pip
# Cython 0.29.x is the version p4a's recipes are validated against.
pip install "cython==0.29.36" buildozer
# Cache the Android SDK/NDK + p4a build dir so reruns are fast.
- name: Cache buildozer global dir
uses: actions/cache@v4
with:
path: ~/.buildozer
# Salted with the p4a pin. restore-keys is scoped to the SAME pin so a
# minor spec edit reuses the already-built recipes from a prior run,
# but a pin change still starts clean (no stale-toolchain contamination).
key: buildozer-global-${{ runner.os }}-p4a-2023.09.16-${{ hashFiles('player/buildozer.spec') }}
restore-keys: buildozer-global-${{ runner.os }}-p4a-2023.09.16-
- name: Cache buildozer local dir
uses: actions/cache@v4
with:
path: player/.buildozer
key: buildozer-local-${{ runner.os }}-p4a-2023.09.16-${{ hashFiles('player/buildozer.spec') }}
restore-keys: buildozer-local-${{ runner.os }}-p4a-2023.09.16-
# Bundle a real map so the APK loads an actual package (the loader path
# runs on-device). Tidy_Test.json uses the bundled 'tidy' plugin, so this
# also exercises the on-device plugin loader + runtime. The plugin's code
# and model ship in the APK via `plugins/*` in buildozer.spec, so the
# make_pak "missing asset" note for the plugin model is expected and
# harmless. Swap for maps/Simple_Map_Test.json for a plugin-free build.
- name: Bundle sample game package
run: |
python -m player.tools.make_pak maps/Tidy_Test.json \
-o player/game.fiopak --root . --title "Fio Tidy Demo"
- name: Build debug APK
working-directory: player
run: |
# Non-interactive: auto-accept the Android SDK licences.
yes | buildozer android debug || buildozer android debug
- name: Locate APK
id: apk
run: |
APK=$(find player/bin -name '*.apk' | head -n1)
echo "path=$APK" >> "$GITHUB_OUTPUT"
echo "Built: $APK"
- name: Upload APK artifact
uses: actions/upload-artifact@v4
with:
name: fio-player-debug-apk
path: player/bin/*.apk
if-no-files-found: error