-
Notifications
You must be signed in to change notification settings - Fork 0
219 lines (186 loc) · 6.13 KB
/
build.yml
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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
name: Build and Release
on:
push:
branches: [ axis ]
tags:
- 'v*.*.*'
pull_request:
branches: [ axis ]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: write
jobs:
android-build:
runs-on: ubuntu-latest
strategy:
matrix:
abi: [arm64-v8a, armeabi-v7a, x86_64, x86]
steps:
- uses: actions/checkout@v4
with:
submodules: 'recursive'
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
- name: Setup Android SDK
uses: android-actions/setup-android@v3
- name: Setup NDK
uses: nttld/setup-ndk@v1
with:
ndk-version: r25c
local-cache: true
- name: Install Build Dependencies
run: |
sudo apt-get update
sudo apt-get install -y cmake ninja-build
- name: Install xmake
run: |
wget https://xmake.io/shget.text -O - | bash
source ~/.xmake/profile
- name: Set SDK and NDK path
run: |
echo "SDK_PATH=$ANDROID_SDK_ROOT" >> $GITHUB_ENV
echo "NDK_PATH=$ANDROID_NDK_ROOT" >> $GITHUB_ENV
- name: Cache SDL builds
uses: actions/cache@v3
with:
path: |
vendor/SDL/build-android-prefab
android/app/libs
key: ${{ runner.os }}-sdl-${{ matrix.abi }}-${{ hashFiles('vendor/SDL/**') }}
restore-keys: |
${{ runner.os }}-sdl-${{ matrix.abi }}-
- name: Build SDL2
run: |
if [ ! -f "android/app/libs/SDL2-*.aar" ]; then
cd vendor/SDL/build-scripts
chmod +x android-prefab.sh
./android-prefab.sh
mkdir -p ../../../android/app/libs
SDL_AAR=$(find ../build-android-prefab/prefab-* -name "SDL2-*.aar")
cp "$SDL_AAR" ../../../android/app/libs/
fi
- name: Build SDL Dependencies
run: |
xmake build_sdl_android --ARCH=${{ matrix.abi }}
- name: Build Android Project
run: |
xmake f -p android --arch=${{ matrix.abi }} --ndk=$ANDROID_NDK_ROOT
xmake
- name: Decode Keystore
run: |
mkdir -p android/app/app
echo "${{ secrets.RELEASE_KEYSTORE }}" > release.keystore.base64
base64 -d release.keystore.base64 > android/app/app/release.keystore
- name: Setup Gradle
run: |
cd android
if [ ! -f "gradlew" ]; then
gradle wrapper
fi
chmod +x gradlew
- name: Build Release APK
env:
KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }}
KEY_ALIAS: ${{ secrets.KEY_ALIAS }}
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
run: |
cd android
./gradlew clean
./gradlew assembleRelease --warning-mode all
- name: Upload Artifacts
uses: actions/upload-artifact@v3
with:
name: android-release-apk-${{ matrix.abi }}
path: android/app/build/outputs/apk/release/app-${{ matrix.abi }}-release.apk
linux-build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: 'recursive'
- name: Install Dependencies
run: |
sudo apt-get update
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y \
build-essential \
clang \
lld \
cmake \
ninja-build \
pkg-config \
wget \
git \
libsdl2-dev \
libsdl2-image-dev \
libsdl2-ttf-dev \
libsdl2-gfx-dev
- name: Install xmake
run: |
wget https://xmake.io/shget.text -O - | bash
source ~/.xmake/profile
- name: Build
run: |
xmake f -p linux -y
xmake -y
mkdir -p artifacts/myquest-linux-x86_64
cp build/clay/main artifacts/myquest-linux-x86_64/myquest
cp -r fonts artifacts/myquest-linux-x86_64/
cp -r images artifacts/myquest-linux-x86_64/
chmod +x artifacts/myquest-linux-x86_64/myquest
cd artifacts
tar czf myquest-linux-x86_64.tar.gz myquest-linux-x86_64/
- name: Upload Artifacts
uses: actions/upload-artifact@v3
with:
name: linux-x86_64-build
path: artifacts/myquest-linux-x86_64.tar.gz
create-release:
needs: [android-build, linux-build]
runs-on: ubuntu-latest
steps:
- name: Download Android Artifacts
uses: actions/download-artifact@v3
with:
path: android-artifacts
- name: Download Linux Artifacts
uses: actions/download-artifact@v3
with:
path: linux-artifacts
- name: Display structure of downloaded files
run: ls -R
- name: Generate date
id: date
if: "!startsWith(github.ref, 'refs/tags/')"
run: echo "date=$(date +'%Y%m%d')" >> $GITHUB_OUTPUT
- name: Create Nightly Release
if: "!startsWith(github.ref, 'refs/tags/')"
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: nightly-${{ steps.date.outputs.date }}
name: Development Build ${{ steps.date.outputs.date }}
draft: false
prerelease: true
files: |
android-artifacts/android-release-apk-*/app-*-release.apk
linux-artifacts/linux-x86_64-build/myquest-linux-x86_64.tar.gz
- name: Create Tagged Release
if: startsWith(github.ref, 'refs/tags/')
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref_name }}
name: Release ${{ github.ref_name }}
draft: false
prerelease: false
generate_release_notes: true
files: |
android-artifacts/android-release-apk-*/app-*-release.apk
linux-artifacts/linux-x86_64-build/myquest-linux-x86_64.tar.gz