Skip to content

Create mobile_build.yml #1

Create mobile_build.yml

Create mobile_build.yml #1

Workflow file for this run

name: Build Mobile Applications
on:
# Trigger the mobile build on pushes to main and pull requests
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
# Android build job. Uses the Ubuntu runner to download the Android
# command‐line tools and NDK, configures CMake for Android, and
# packages the resulting APK with the assets folder. The APK is built
# targeting Android 7.0+ (platform level 24) for 64‑bit ARM (arm64‑v8a).
android:
runs-on: ubuntu-latest
env:
ANDROID_HOME: ${{ github.workspace }}/android-sdk
ANDROID_SDK_ROOT: ${{ github.workspace }}/android-sdk
steps:
- name: Checkout source
uses: actions/checkout@v3
- name: Set up JDK
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: '11'
- name: Install Android SDK and NDK
run: |
set -e
mkdir -p "$ANDROID_HOME" && cd "$ANDROID_HOME"
# Download the latest command line tools. The version number may need updating over time.
curl -sSL -o cmdline-tools.zip \
https://dl.google.com/android/repository/commandlinetools-linux-9477386_latest.zip
unzip -q cmdline-tools.zip
rm cmdline-tools.zip
# Move cmdline-tools into the expected directory structure
mkdir -p cmdline-tools/latest
mv cmdline-tools/* cmdline-tools/latest/
# Add sdkmanager to PATH
export PATH="$ANDROID_HOME/cmdline-tools/latest/bin:$PATH"
yes | sdkmanager --licenses
sdkmanager \
"platform-tools" \
"platforms;android-33" \
"build-tools;33.0.2" \
"ndk;27.2.12479018" \
"cmake;3.22.1"
- name: Configure Android build with CMake
run: |
set -e
export ANDROID_NDK_HOME="$ANDROID_HOME/ndk/27.2.12479018"
cmake -S . -B build/android \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_TOOLCHAIN_FILE="$ANDROID_NDK_HOME/build/cmake/android.toolchain.cmake" \
-DANDROID_PLATFORM=android-24 \
-DANDROID_ABI=arm64-v8a
- name: Build Android
run: |
cmake --build build/android --config Release --parallel
- name: Package Android binary and assets
run: |
set -e
# Create a staging directory for packaging
mkdir -p packaged
# Copy the output APK (if it exists) or built library/executable
if [ -f build/android/mw_recreation.apk ]; then cp build/android/mw_recreation.apk packaged/; fi
if [ -f build/android/mw_recreation ]; then cp build/android/mw_recreation packaged/; fi
# Copy the assets directory
cp -r assets packaged/assets
# Create a zip archive named android-latest.zip
zip -r android-latest.zip packaged
- name: Upload Android package
uses: actions/upload-artifact@v4
with:
name: android-latest
path: android-latest.zip
# iOS build job. Runs on a macOS runner because iOS compilation requires
# Xcode. It configures CMake to generate an Xcode project targeting
# arm64 devices. The deployment target is set to iOS 9.0; if that
# fails in practice, updating to iOS 12 or 15 can be done by changing
# the deployment target below. Packaging simply zips the resulting
# .app bundle together with the assets directory.
ios:
runs-on: macos-12
steps:
- name: Checkout source
uses: actions/checkout@v3
- name: Install dependencies
run: |
brew update
brew install cmake
- name: Configure iOS build with CMake
run: |
set -e
cmake -S . -B build/ios -G Xcode \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_OSX_SYSROOT=iphoneos \
-DCMAKE_OSX_ARCHITECTURES=arm64 \
-DCMAKE_OSX_DEPLOYMENT_TARGET=9.0
- name: Build iOS
run: |
cmake --build build/ios --config Release --parallel
- name: Package iOS binary and assets
run: |
set -e
mkdir -p packaged
# Find the .app bundle generated by the Xcode build and copy it into packaged
find build/ios -name '*.app' -print -exec cp -R {} packaged/mw_recreation.app \; -quit
cp -r assets packaged/assets
zip -r macos-latest.zip packaged
- name: Upload iOS package
uses: actions/upload-artifact@v4
with:
name: macos-latest
path: macos-latest.zip