Add GitHub Actions workflow for iOS build #10
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build Android App with SDL2 | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Install required packages | |
run: | | |
sudo apt update | |
sudo apt install -y build-essential git wget unzip | |
- name: Install Android SDK and NDK | |
run: | | |
mkdir -p $HOME/android-sdk $HOME/android-ndk | |
wget https://dl.google.com/android/repository/commandlinetools-linux-6609375_latest.zip | |
unzip commandlinetools-linux-6609375_latest.zip -d $HOME/android-sdk | |
rm commandlinetools-linux-6609375_latest.zip | |
echo "export ANDROID_HOME=$HOME/android-sdk" >> $GITHUB_ENV | |
echo "export PATH=$ANDROID_HOME/cmdline-tools/latest/bin:$ANDROID_HOME/platform-tools:$PATH" >> $GITHUB_ENV | |
yes | sdkmanager --sdk_root=$HOME/android-sdk "platforms;android-26" "ndk;21.4.7075529" "platform-tools" "build-tools;30.0.3" | |
- name: Accept licenses | |
run: yes | sdkmanager --licenses | |
- name: Clone SDL2 for Android | |
run: | | |
git clone https://github.com/libsdl-org/SDL.git | |
cd SDL | |
git checkout main # Or specify the desired branch/tag | |
- name: Build SDL2 for Android | |
run: | | |
cd SDL/android | |
./build-sdl.sh | |
echo "SDL2 built for Android." | |
- name: Compile the Android app | |
run: | | |
mkdir -p build | |
cd build | |
$ANDROID_HOME/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/bin/clang \ | |
-o MyApp.so \ | |
-I$HOME/android-sdk/ndk/21.4.7075529/sources/android/native_app_glue \ | |
-I$HOME/android-sdk/ndk/21.4.7075529/sources/SDL2 \ | |
../main.c \ | |
-lSDL2 \ | |
-target aarch64-linux-android21 \ | |
-fPIC | |
- name: Build APK | |
run: | | |
cd build | |
echo "Creating Android APK..." | |
cat <<EOF > Android.mk | |
LOCAL_PATH := \$(call my-dir) | |
include \$(CLEAR_VARS) | |
LOCAL_MODULE := MyApp | |
LOCAL_SRC_FILES := MyApp.so | |
include \$(BUILD_SHARED_LIBRARY) | |
EOF | |
echo "Creating Application.mk..." | |
cat <<EOF > Application.mk | |
APP_ABI := arm64-v8a | |
APP_PLATFORM := android-26 | |
EOF | |
cd $HOME/android-sdk/ndk/21.4.7075529/build/outputs/apk | |
ndk-build NDK_PROJECT_PATH=$HOME/android-sdk/ndk/21.4.7075529/build \ | |
APP_BUILD_SCRIPT=Android.mk \ | |
NDK_APPLICATION_MK=Application.mk | |
- name: Upload the build artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: android-app | |
path: $HOME/android-sdk/ndk/21.4.7075529/build/outputs/apk/*.apk |