-
Notifications
You must be signed in to change notification settings - Fork 0
138 lines (125 loc) · 5.26 KB
/
mobile_build.yml
File metadata and controls
138 lines (125 loc) · 5.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
name: Build for Mobile
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