You've already forked SpaghettiKart
mirror of
https://github.com/izzy2lost/SpaghettiKart.git
synced 2026-03-26 16:57:37 -07:00
141 lines
4.3 KiB
YAML
141 lines
4.3 KiB
YAML
name: Android Build
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
inputs:
|
|
build_type:
|
|
description: 'Build type'
|
|
required: true
|
|
default: 'debug'
|
|
type: choice
|
|
options:
|
|
- debug
|
|
- release
|
|
push:
|
|
branches: [ main ]
|
|
paths:
|
|
- 'android/**'
|
|
- 'src/**'
|
|
- 'CMakeLists.txt'
|
|
pull_request:
|
|
branches: [ main ]
|
|
paths:
|
|
- 'android/**'
|
|
- 'src/**'
|
|
- 'CMakeLists.txt'
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
generate-port-o2r:
|
|
runs-on: ubuntu-22.04
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
submodules: true
|
|
- name: Install dependencies
|
|
run: sudo apt-get install gcc g++ git cmake ninja-build lsb-release
|
|
- name: ccache
|
|
uses: hendrikmuhs/ccache-action@v1.2.18
|
|
with:
|
|
key: ${{ runner.os }}-o2r-ccache-${{ github.ref }}-${{ github.sha }}
|
|
restore-keys: |
|
|
${{ runner.os }}-o2r-ccache-${{ github.ref }}
|
|
${{ runner.os }}-o2r-ccache-
|
|
- name: Cache build folders
|
|
uses: actions/cache@v4
|
|
with:
|
|
key: ${{ runner.os }}-o2r-build-${{ github.ref }}-${{ github.sha }}
|
|
restore-keys: |
|
|
${{ runner.os }}-o2r-build-${{ github.ref }}
|
|
${{ runner.os }}-o2r-build-
|
|
path: |
|
|
torch/cmake-build-release
|
|
- name: Generate spaghetti.o2r
|
|
run: |
|
|
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
|
|
make -C torch type=release -j3
|
|
torch/cmake-build-release/torch pack assets spaghetti.o2r o2r
|
|
- uses: actions/upload-artifact@v4
|
|
with:
|
|
name: spaghetti.o2r
|
|
path: spaghetti.o2r
|
|
retention-days: 1
|
|
|
|
build-android:
|
|
needs: generate-port-o2r
|
|
runs-on: ubuntu-24.04
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
submodules: true
|
|
- name: Install dependencies
|
|
run: sudo apt-get install -y ninja-build
|
|
- name: Download spaghetti.o2r
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: spaghetti.o2r
|
|
path: android/app/src/main/assets
|
|
- name: Configure Gradle permissions
|
|
run: chmod +x android/gradlew
|
|
|
|
# Set up signing for release builds
|
|
- name: Setup signing keystore (Release only)
|
|
if: github.event.inputs.build_type == 'release' || github.ref == 'refs/heads/main'
|
|
run: |
|
|
echo "$KEYSTORE_BASE64" | base64 -d > android/app/release.keystore
|
|
if [ ! -f android/app/release.keystore ]; then
|
|
echo "Failed to create keystore file"
|
|
exit 1
|
|
fi
|
|
echo "Keystore file created successfully:"
|
|
ls -la android/app/release.keystore
|
|
file android/app/release.keystore
|
|
env:
|
|
KEYSTORE_BASE64: ${{ secrets.KEYSTORE_BASE64 }}
|
|
|
|
# Build Debug APK
|
|
- name: Build Debug APK
|
|
if: github.event.inputs.build_type == 'debug' || github.event.inputs.build_type == ''
|
|
run: |
|
|
cd android/
|
|
./gradlew assembleDebug -P elfBuildType=RelWithDebInfo
|
|
mv app/build/outputs/apk/debug/app-debug.apk ../spaghettikart-debug.apk
|
|
|
|
# Build Release APK (signed)
|
|
- name: Build Release APK
|
|
if: github.event.inputs.build_type == 'release' || github.ref == 'refs/heads/main'
|
|
run: |
|
|
cd android/
|
|
./gradlew assembleRelease -P elfBuildType=Release
|
|
mv app/build/outputs/apk/release/app-release.apk ../spaghettikart-release.apk
|
|
env:
|
|
KEYSTORE_FILE: release.keystore
|
|
KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }}
|
|
KEY_ALIAS: ${{ secrets.KEY_ALIAS }}
|
|
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
|
|
|
|
# Upload Debug APK
|
|
- name: Upload Debug APK
|
|
if: github.event.inputs.build_type == 'debug' || github.event.inputs.build_type == ''
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: spaghetti-kart-debug-apk
|
|
path: spaghettikart-debug.apk
|
|
|
|
# Upload Release APK
|
|
- name: Upload Release APK
|
|
if: github.event.inputs.build_type == 'release' || github.ref == 'refs/heads/main'
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: spaghetti-kart-release-apk
|
|
path: spaghettikart-release.apk
|
|
|
|
# Clean up keystore
|
|
- name: Clean up keystore
|
|
if: always()
|
|
run: rm -f android/app/release.keystore
|
|
|