Repository navigation
272 lines (236 loc) · 9.73 KB
/
Copy pathandroid.yml
File metadata and controls
272 lines (236 loc) · 9.73 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
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
name: Android
on:
push:
paths:
- 'app/**'
- 'core/**'
- 'images/**'
- 'qgsquick/**'
- 'scripts/**'
- '.github/workflows/android.yml'
release:
types:
- published
concurrency:
group: ci-${{github.ref}}-android
cancel-in-progress: true
jobs:
android_build:
if: ( github.repository == 'lutraconsulting/input' ) && (!contains(github.event.head_commit.message, 'Translate '))
runs-on: macos-10.15
env:
QT_VERSION: '5.14.2'
ANDROIDAPI: 24
ANDROID_NDK_PLATFORM: android-24
NDK_VERSION: r21
SDK_PLATFORM: android-30
SDK_BUILD_TOOLS: 28.0.3
INPUT_SDK_VERSION: android-macOS-20220212-65
CCACHE_DIR: /Users/runner/work/ccache
GITHUB_TOKEN: ${{ secrets.INPUTAPP_BOT_GITHUB_TOKEN }}
INPUTKEYSTORE_STOREPASS: ${{ secrets.INPUTKEYSTORE_STOREPASS }}
CACHE_VERSION: 4
steps:
- uses: actions/checkout@v2
# 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: |
brew install bison flex automake shtool gtk-doc
echo "/usr/local/opt/flex/bin" >> $GITHUB_PATH
echo "/usr/local/opt/bison/bin" >> $GITHUB_PATH
brew install gnupg
brew install [email protected]
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
# Qt
- name: Cache Qt
id: cache-qt
uses: pat-s/[email protected]
with:
path: ${{ github.workspace }}/Qt
key: ${{ runner.os }}-QtCache-v2-${{ env.QT_VERSION }}-android-${{ env.CACHE_VERSION }}
- name: Install Qt
uses: jurplel/install-qt-action@v2
with:
version: ${{ env.QT_VERSION }}
target: android
arch: android
dir: ${{ github.workspace }}
cached: ${{ steps.cache-qt.outputs.cache-hit }}
# 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-v1-${{ env.INPUT_SDK_VERSION }}-${{ env.CACHE_VERSION }}
- name: Install Input-SDK
if: steps.cache-input-sdk.outputs.cache-hit != 'true'
run: |
wget -O \
input-sdk.tar.gz \
https://github.com/lutraconsulting/input-sdk/releases/download/${{ env.INPUT_SDK_VERSION }}/input-sdk-qt-${{ env.QT_VERSION }}-${{ env.INPUT_SDK_VERSION }}.tar.gz
mkdir -p ${{ github.workspace }}/input-sdk
cd ${{ github.workspace }}/input-sdk
tar -xvzf ${{ github.workspace }}/input-sdk.tar.gz
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
# Android SDK & NDK
- uses: nttld/setup-ndk@v1
id: setup-ndk
with:
ndk-version: r21e
add-to-path: true
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Setup Android SDK
uses: malinskiy/action-android/install-sdk@release/0.1.2
- name: Install Android Tools
run: |
sdkmanager --licenses && sdkmanager --verbose "platforms;${SDK_PLATFORM}" "build-tools;${SDK_BUILD_TOOLS}" tools platform-tools
# Build Input App
- name: Export app/config.pri
run: |
touch ./app/config.pri
echo -e "android {" >> ./app/config.pri
echo -e " INPUT_SDK_PATH=${{ github.workspace }}/input-sdk" >> ./app/config.pri
echo -e " QGIS_QUICK_DATA_PATH = INPUT" >> ./app/config.pri
echo -e " QMAKE_CXX = ccache \$\$QMAKE_CXX " >> ./app/config.pri
echo -e "}" >> ./app/config.pri
cat ./app/config.pri
- name: Build armeabi-v7a APK
env:
ARCH: armeabi-v7a
ANDROID_NDK_ROOT: ${{ steps.setup-ndk.outputs.ndk-path }}
ANDROID_NDK_HOST: darwin-x86_64
QT_BASE: ${{ github.workspace }}/Qt/${{ env.QT_VERSION }}/android
STAGE_PATH: ${{ github.workspace }}/input-sdk/android/stage/armeabi-v7a
SOURCE_DIR: ${{ github.workspace }}
run: |
mkdir -p ${{ github.workspace }}/build-apk-$ARCH
cd ${{ github.workspace }}/build-apk-$ARCH
../scripts/android-apk.bash
- name: Build arm64-v8a APK
env:
ARCH: arm64-v8a
ANDROID_NDK_ROOT: ${{ steps.setup-ndk.outputs.ndk-path }}
ANDROID_NDK_HOST: darwin-x86_64
QT_BASE: ${{ github.workspace }}/Qt/${{ env.QT_VERSION }}/android
SOURCE_DIR: ${{ github.workspace }}
run: |
mkdir -p ${{ github.workspace }}/build-apk-$ARCH
cd ${{ github.workspace }}/build-apk-$ARCH
../scripts/android-apk.bash
- name: Upload v8 APK to Artifacts
uses: actions/upload-artifact@v2
with:
path: ${{ github.workspace }}/build-apk-arm64-v8a/input/out/build/outputs/apk/release/out-release-signed.apk
name: arm64 apk
- name: Upload v7 APK to Artifacts
uses: actions/upload-artifact@v2
with:
path: ${{ github.workspace }}/build-apk-armeabi-v7a/input/out/build/outputs/apk/release/out-release-signed.apk
name: armeabi apk
- name: Download repo history
if: ${{ env.GIT_BRANCH }} == "master"
uses: actions/checkout@v2
with:
path: input-history
fetch-depth: 0 # fetch all history
- name: Calculate version code
if: ${{ env.GIT_BRANCH }} == "master"
env:
COMMIT_OFFSET: 1639 # number of commits since beginning. We use this number as offset to start counting from one
VERSIONS_MIN: 101005 # max VERSION_CODE number we had when we used version name in code. We iterate from this number by a number of commits
run: |
cd input-history
NUM_OF_COMMITS=`git rev-list --count HEAD`
echo "Number of commits: $NUM_OF_COMMITS, with offset: $((NUM_OF_COMMITS - ${{ env.COMMIT_OFFSET }}))"
NUM_OF_COMMITS_WITH_OFFSET=$((NUM_OF_COMMITS - ${{ env.COMMIT_OFFSET }}))
VERSION_CODE=$((VERSIONS_MIN + NUM_OF_COMMITS_WITH_OFFSET))
echo "CI_VERSION_CODE=${VERSION_CODE}" >> $GITHUB_ENV
echo "CALCULATED VERSION CODE: ${VERSION_CODE}"
- name: Build AAB
if: ${{ env.GIT_BRANCH }} == "master"
env:
ARCH: 'armeabi-v7a arm64-v8a'
ANDROID_NDK_ROOT: ${{ steps.setup-ndk.outputs.ndk-path }}
ANDROID_NDK_HOST: darwin-x86_64
QT_BASE: ${{ github.workspace }}/Qt/${{ env.QT_VERSION }}/android
SOURCE_DIR: ${{ github.workspace }}
run: |
pwd
echo "Version code: ${{env.CI_VERSION_CODE}}"
mkdir -p ${{ github.workspace }}/build-aab
cd ${{ github.workspace }}/build-aab
../scripts/android-aab.bash
- name: Upload AAB to Artifacts
if: ${{ env.GIT_BRANCH }} == "master"
uses: actions/upload-artifact@v2
with:
path: ${{ github.workspace }}/build-aab/input/out/build/outputs/bundle/release/out-release.aab
name: aab bundle
- name: Check generated files
run: |
find ${{ github.workspace }}/build-* -name "*.apk" -or -name "*.aab"