-
Notifications
You must be signed in to change notification settings - Fork 65
300 lines (256 loc) · 11 KB
/
android.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
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
name: Android
on:
push:
paths:
- 'app/**'
- 'core/**'
- 'scripts/**'
- 'cmake/**'
- 'cmake_templates/**'
- 'CMakeLists.txt'
- '.github/workflows/android.yml'
release:
types:
- published
concurrency:
group: ci-${{github.ref}}-android
cancel-in-progress: true
jobs:
android_build:
if: ( github.repository == 'MerginMaps/mobile' ) && (!contains(github.event.head_commit.message, 'Translate '))
runs-on: macos-13
env:
QT_VERSION: '6.6.3' # use scripts/update_qt_version.bash to change
NDK_VERSION: r25
NDK_VERSION_FULL: r25b
JDK_VERSION: 11
SDK_PLATFORM: android-34
SDK_BUILD_TOOLS: 34.0.0
INPUT_SDK_VERSION_ARM: arm-android-20240517-224
INPUT_SDK_VERSION_ARM64: arm64-android-20240517-224
CCACHE_DIR: /Users/runner/work/ccache
GITHUB_TOKEN: ${{ secrets.INPUTAPP_BOT_GITHUB_TOKEN }}
CACHE_VERSION: 0
CMAKE_VERSION: '3.29.0'
QT_ANDROID_KEYSTORE_ALIAS: input
QT_ANDROID_KEYSTORE_KEY_PASS: ${{ secrets.INPUTKEYSTORE_STOREPASS }}
QT_ANDROID_KEYSTORE_STORE_PASS: ${{ secrets.INPUTKEYSTORE_STOREPASS }}
XC_VERSION: ${{ '15.2' }}
steps:
- uses: actions/checkout@v3
- name: Select latest Xcode
run: "sudo xcode-select -s /Applications/Xcode_$XC_VERSION.app"
# CCache
- name: Prepare build cache for pull request
uses: pat-s/[email protected]
if: github.event_name == 'pull_request'
with:
path: ${{ env.CCACHE_DIR }}
key: build-android-ccache-${{ github.actor }}-${{ github.head_ref }}-${{ github.sha }}
# The head_ref or source branch of the pull request in a workflow run.
# The base_ref or target branch of the pull request in a workflow run.
restore-keys: |
build-android-ccache-${{ github.actor }}-${{ github.head_ref }}-
build-android-ccache-refs/heads/${{ github.base_ref }}-
build-android-ccache-refs/heads/master-
- name: Prepare build cache for branch/tag
# use a fork of actions/cache@v2 to upload cache even when the build or test failed
uses: pat-s/[email protected]
if: github.event_name != 'pull_request'
with:
path: ${{ env.CCACHE_DIR }}
# The branch or tag ref that triggered the workflow run. For branches this in the format refs/heads/<branch_name>, and for tags it is refs/tags/<tag_name>
key: build-android-ccache-${{ github.ref }}-${{ github.sha }}
restore-keys: |
build-android-ccache-${{ github.ref }}-
build-android-ccache-refs/heads/master-
- name: Install ccache
run: |
mkdir -p ${CCACHE_DIR}
brew install ccache
ccache --set-config=max_size=2.0G
ccache -s
- name: Install Build Dependencies
run: |
pip3 install -U pip
pip3 install aqtinstall
brew install gnupg
brew install [email protected]
brew install ninja
if [[ ${{ github.ref }} == refs/tags/* ]]
then
export GIT_TAG="${GITHUB_REF//refs\/tags\//}"
export GIT_BRANCH=""
else
export GIT_TAG=""
export GIT_BRANCH="${GITHUB_REF//refs\/heads\//}"
fi
echo "GIT_TAG: $GIT_TAG"
echo "GIT_BRANCH: $GIT_BRANCH"
echo "GIT_TAG=$GIT_TAG" >> $GITHUB_ENV
echo "GIT_BRANCH=$GIT_BRANCH" >> $GITHUB_ENV
- name: Install CMake and Ninja
uses: lukka/get-cmake@latest
with:
cmakeVersion: ${{ env.CMAKE_VERSION }}
- name: Cache Qt
id: cache-qt
uses: pat-s/[email protected]
with:
path: ${{ github.workspace }}/Qt
key: ${{ runner.os }}-QtCache-v6-${{ env.QT_VERSION }}-android
- name: Install Qt
if: steps.cache-qt.outputs.cache-hit != 'true'
run: |
aqt install-qt \
mac android ${{ env.QT_VERSION }} android_arm64_v8a \
-m qtsensors qtconnectivity qt5compat qtmultimedia qtpositioning qtshadertools \
-O ${{ github.workspace }}/Qt
aqt install-qt \
mac android ${{ env.QT_VERSION }} android_armv7 \
-m qtsensors qtconnectivity qt5compat qtmultimedia qtpositioning qtshadertools \
-O ${{ github.workspace }}/Qt
aqt install-qt \
mac desktop ${{ env.QT_VERSION }} \
-m qtsensors qtconnectivity qt5compat qtmultimedia qtpositioning qtshadertools \
-O ${{ github.workspace }}/Qt
# Android SDK & NDK
- uses: nttld/setup-ndk@v1
id: setup-ndk
with:
ndk-version: ${{ env.NDK_VERSION_FULL }}
add-to-path: true
- name: Set up JDK
uses: actions/setup-java@v3
with:
java-version: ${{ env.JDK_VERSION }}
distribution: zulu
- name: Setup Android SDK
uses: malinskiy/action-android/install-sdk@release/0.1.4
- name: Install Android Tools
run: |
sdkmanager --licenses && sdkmanager --verbose "platforms;${SDK_PLATFORM}" "build-tools;${SDK_BUILD_TOOLS}" tools platform-tools
# Input SDK
- name: Cache Input-SDK
id: cache-input-sdk
uses: pat-s/[email protected]
with:
path: ${{ github.workspace }}/input-sdk
key: ${{ runner.os }}-input-sdk-v0-${{ env.INPUT_SDK_VERSION_ARM }}-${{ env.CACHE_VERSION }}
- name: Install Input-SDK
if: steps.cache-input-sdk.outputs.cache-hit != 'true'
run: |
# download
wget -O \
input-sdk-arm-android.tar.gz \
https://github.com/MerginMaps/mobile-sdk/releases/download/${{ env.INPUT_SDK_VERSION_ARM }}/mergin-maps-input-sdk-qt-${{ env.QT_VERSION }}-${{ env.INPUT_SDK_VERSION_ARM }}.tar.gz
wget -O \
input-sdk-arm64-android.tar.gz \
https://github.com/MerginMaps/mobile-sdk/releases/download/${{ env.INPUT_SDK_VERSION_ARM64 }}/mergin-maps-input-sdk-qt-${{ env.QT_VERSION }}-${{ env.INPUT_SDK_VERSION_ARM64 }}.tar.gz
# unpack
mkdir -p ${{ github.workspace }}/input-sdk/arm-android
cd ${{ github.workspace }}/input-sdk/arm-android
tar -xvzf ${{ github.workspace }}/input-sdk-arm-android.tar.gz
mkdir -p ${{ github.workspace }}/input-sdk/arm64-android
cd ${{ github.workspace }}/input-sdk/arm64-android
tar -xvzf ${{ github.workspace }}/input-sdk-arm64-android.tar.gz
# check
ls ${{ github.workspace }}/input-sdk
- name: Extract Mergin API_KEY
env:
MERGINSECRETS_DECRYPT_KEY: ${{ secrets.MERGINSECRETS_DECRYPT_KEY }}
run: |
cd core/
/usr/local/opt/[email protected]/bin/openssl \
aes-256-cbc -d \
-in merginsecrets.cpp.enc \
-out merginsecrets.cpp \
-k "$MERGINSECRETS_DECRYPT_KEY" \
-md md5
- name: Extract GPS keystore
env:
INPUTKEYSTORE_DECRYPT_KEY: ${{ secrets.INPUTKEYSTORE_DECRYPT_KEY }}
run: |
/usr/local/opt/[email protected]/bin/openssl \
aes-256-cbc -d \
-in Input_keystore.keystore.enc \
-out Input_keystore.keystore \
-k $INPUTKEYSTORE_DECRYPT_KEY \
-md md5
PATH_TO_KEYSTORE=`pwd`/Input_keystore.keystore
echo "path to keystore $PATH_TO_KEYSTORE"
echo "QT_ANDROID_KEYSTORE_PATH=$PATH_TO_KEYSTORE" >> $GITHUB_ENV
# Build Input App
- name: Calculate build number
env:
OFFFSET: 10 # offset for build number - due to previous builds ~ new builds must always have a higher number
run: |
BUILD_NUM=$GITHUB_RUN_NUMBER$((GITHUB_RUN_ATTEMPT + OFFFSET))
echo "INPUT_VERSION_CODE=${BUILD_NUM}" >> $GITHUB_ENV
echo "Version code: ${BUILD_NUM}"
- name: Configure Input
env:
ANDROID_NDK_ROOT: ${{ steps.setup-ndk.outputs.ndk-path }}
ANDROID_NDK_HOST: darwin-x86_64
QT_BASE: ${{ github.workspace }}/Qt/${{ env.QT_VERSION }}
INPUT_SDK_ANDROID_BASE: ${{ github.workspace }}/input-sdk
run: |
mkdir -p ${{ github.workspace }}/build-Input
cd ${{ github.workspace }}/build-Input
cmake \
-DCMAKE_BUILD_TYPE=Release \
-DQT_ANDROID_ABIS="arm64-v8a;armeabi-v7a" \
-DQT_HOST_PATH=$QT_BASE/macos \
-DQT_ANDROID_SIGN_APK=Yes \
-DQT_ANDROID_SIGN_AAB=Yes \
-DUSE_MM_SERVER_API_KEY=Yes \
-DCMAKE_TOOLCHAIN_FILE=$QT_BASE/android_arm64_v8a/lib/cmake/Qt6/qt.toolchain.cmake \
-GNinja \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-S ../ \
-B ./
- name: Build APK
env:
ANDROID_NDK_ROOT: ${{ steps.setup-ndk.outputs.ndk-path }}
ANDROID_NDK_HOST: darwin-x86_64
QT_BASE: ${{ github.workspace }}/Qt/${{ env.QT_VERSION }}
INPUT_SDK_ANDROID_BASE: ${{ github.workspace }}/input-sdk
run: |
cd ${{ github.workspace }}/build-Input
ninja apk
echo "APKs:"
find . | grep .apk
- name: Rename APK artefacts
run: |
mv \
${{ github.workspace }}/build-Input/app/android-build/build/outputs/apk/release/android-build-release-signed.apk \
${{ github.workspace }}/merginmaps-${{ env.INPUT_VERSION_CODE }}.apk
- name: Upload APK to Artifacts
uses: actions/upload-artifact@v3
with:
path: ${{ github.workspace }}/merginmaps-${{ env.INPUT_VERSION_CODE }}.apk
name: Mergin Maps ${{ env.INPUT_VERSION_CODE }} APK [v7 + v8a]
- name: Build AAB
if: ${{ github.ref_name == 'master' || github.ref_type == 'tag' }}
env:
ANDROID_NDK_ROOT: ${{ steps.setup-ndk.outputs.ndk-path }}
ANDROID_NDK_HOST: darwin-x86_64
QT_BASE: ${{ github.workspace }}/Qt/${{ env.QT_VERSION }}
INPUT_SDK_ANDROID_BASE: ${{ github.workspace }}/input-sdk
run: |
cd ${{ github.workspace }}/build-Input
ninja aab
echo "AAB:"
find . | grep .aab
- name: Rename AAB artefacts
if: ${{ github.ref_name == 'master' || github.ref_type == 'tag' }}
run: |
mv \
${{ github.workspace }}/build-Input/app/android-build/build/outputs/bundle/release/android-build-release.aab \
${{ github.workspace }}/merginmaps-${{ env.INPUT_VERSION_CODE }}.aab
- name: Upload AAB to Artifacts
if: ${{ github.ref_name == 'master' || github.ref_type == 'tag' }}
uses: actions/upload-artifact@v3
with:
path: ${{ github.workspace }}/merginmaps-${{ env.INPUT_VERSION_CODE }}.aab
name: Mergin Maps ${{ env.INPUT_VERSION_CODE }} AAB