forked from HarbourMasters/SpaghettiKart
-
Notifications
You must be signed in to change notification settings - Fork 5
169 lines (148 loc) · 4.9 KB
/
Copy pathandroid-compile.yml
File metadata and controls
169 lines (148 loc) · 4.9 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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
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/**'
- 'include/**'
- 'courses/**'
- 'assets/**'
- 'yamls/**'
- 'meta/**'
- 'cmake/**'
- 'config.yml'
- 'CMakeLists.txt'
- '.github/workflows/android-compile.yml'
pull_request:
branches: [ main ]
paths:
- 'android/**'
- 'src/**'
- 'include/**'
- 'courses/**'
- 'assets/**'
- 'yamls/**'
- 'meta/**'
- 'cmake/**'
- 'config.yml'
- 'CMakeLists.txt'
- '.github/workflows/android-compile.yml'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
# The engine assets (fonts, shaders, custom tracks) are the one thing the app
# cannot build on-device: packing them needs the Torch executable, and the NDK
# build has no host toolchain. Build it here and ship the result as an APK
# asset. The game's own assets are extracted from the user's ROM on-device.
generate-port-o2r:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Install dependencies
run: sudo apt-get update && sudo apt-get install -y 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: Build Torch
run: |
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
cmake -S torch -B torch/build-host -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DUSE_STANDALONE=ON \
-DBUILD_MK64=ON \
-DBUILD_NAUDIO=ON \
-DBUILD_SM64=OFF \
-DBUILD_SF64=OFF \
-DBUILD_FZERO=OFF \
-DBUILD_MARIO_ARTIST=OFF
cmake --build torch/build-host --parallel
- name: Generate spaghetti.o2r
run: torch/build-host/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: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
- name: Setup Android SDK
uses: android-actions/setup-android@v3
- name: Install dependencies
run: sudo apt-get update && 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
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
# 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
test -s android/app/release.keystore || (echo "Failed to create keystore file" && exit 1)
env:
KEYSTORE_BASE64: ${{ secrets.KEYSTORE_BASE64 }}
- name: Build Debug APK
if: github.event.inputs.build_type == 'debug' || github.event.inputs.build_type == ''
run: |
cd android/
./gradlew assembleDebug
mv app/build/outputs/apk/debug/app-debug.apk ../spaghettikart-debug.apk
- name: Build Release APK
if: github.event.inputs.build_type == 'release' || github.ref == 'refs/heads/main'
run: |
cd android/
./gradlew assembleRelease
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 }}
- 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
- 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
- name: Clean up keystore
if: always()
run: rm -f android/app/release.keystore