Skip to content

Trying to fix 2

Trying to fix 2 #12

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, SDK, NDK, and CMake. Then it invokes the Gradle
# wrapper (android/gradlew) to build a release APK using the project under
# android/. The resulting APK and the repo's assets folder are packaged
# into a single zip. Note: minSdk is 24 (Android 7.0+), targetSdk is 34.
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
# Use JDK 17 to satisfy newer Android Gradle Plugin requirements
java-version: '17'
- 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
# Remove any existing cmdline-tools to avoid nested directories
rm -rf cmdline-tools
unzip -q cmdline-tools.zip
rm cmdline-tools.zip
# The zip extracts a folder named 'cmdline-tools'. Rename it to a temporary name
mv cmdline-tools cmdline-tools-temp
# Create the expected hierarchy and move the extracted tools into 'latest'
mkdir -p cmdline-tools
mv cmdline-tools-temp cmdline-tools/latest
# Add sdkmanager to PATH
export PATH="$ANDROID_HOME/cmdline-tools/latest/bin:$PATH"
yes | sdkmanager --licenses
# Install necessary Android components. We avoid inserting comments mid-command to
# ensure the backslash continuation works correctly. All arguments are quoted to
# prevent shell interpretation of semicolons.
sdkmanager \
"platform-tools" \
"platforms;android-34" \
"build-tools;34.0.0" \
"ndk;27.2.12479018" \
"cmake;3.22.1"
# Build the Android APK using the Gradle wrapper included in the repository. The Gradle build
# will invoke CMake via externalNativeBuild and package the native library and assets into an APK.
- name: Build Android APK
run: |
set -e
# Change into the android project directory where gradlew lives
cd android
# Ensure the wrapper is executable
chmod +x gradlew
# Build a debug APK instead of release. Debug builds are automatically signed
# with the debug keystore and can be installed on devices/emulators without
# additional signing configuration. If you later add a signingConfig for
# release builds, you can switch back to assembleRelease.
./gradlew assembleDebug
- name: Prepare Android APK for upload
run: |
set -e
# Find the generated APK (debug build) and copy it to a predictable location
APK_PATH=$(find android/app/build/outputs -type f -name "*.apk" | head -n 1 || true)
if [ -n "$APK_PATH" ]; then
cp "$APK_PATH" mw_recreation.apk
else
echo "No APK found; build may have failed" && exit 1
fi
- name: Upload Android APK
uses: actions/upload-artifact@v4
with:
name: android-latest
path: mw_recreation.apk
# 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:
# Temporarily disabled iOS build
if: false
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