-
Notifications
You must be signed in to change notification settings - Fork 10
360 lines (315 loc) · 13.7 KB
/
deploy.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
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
name: "Deploy"
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: "deploy"
cancel-in-progress: true
jobs:
build-android:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
qtarch: [android_arm64_v8a, android_armv7]
include:
- qtarch: android_arm64_v8a
qttarget: 'android'
qtversion: '6.8.1'
qtmodules: 'qtcharts qtpositioning'
- qtarch: android_armv7
qttarget: 'android'
qtversion: '6.8.1'
qtmodules: 'qtcharts qtpositioning'
steps:
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y build-essential ninja-build openjdk-17-jdk
echo "JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64/" >> $GITHUB_ENV
# dpkg-query -L openjdk-17-jdk-headless
- uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- name: Install Qt native version (the one provided by aqt doesn't seem to work)
uses: jurplel/install-qt-action@v4
with:
aqtversion: '==3.1.*'
version: ${{ matrix.qtversion }}
host: 'linux'
target: 'desktop'
arch: 'linux_gcc_64'
dir: '${{github.workspace}}/qt'
install-deps: 'true'
cache: true
- name: Set QT_HOST_ROOT_DIR
run: echo "QT_HOST_ROOT_DIR=${QT_ROOT_DIR}" >> "$GITHUB_ENV"
- name: Install Qt crosscompile target version
uses: jurplel/install-qt-action@v4
with:
aqtversion: '==3.1.*'
version: ${{ matrix.qtversion }}
host: linux
target: ${{ matrix.qttarget }}
arch: ${{ matrix.qtarch }}
dir: '${{github.workspace}}/qt'
install-deps: 'true'
modules: ${{ matrix.qtmodules }}
cache: true
- name: Make qt cross binaries executable
run: |
chmod u+x ${QT_ROOT_DIR}/bin/*
- name: Set reusable strings
shell: bash
run: |
BUILD_DIR="build"
APK_TARGET="app"
echo "BUILD_DIR=$BUILD_DIR" >> $GITHUB_ENV
echo "APK_TARGET=$APK_TARGET" >> $GITHUB_ENV
echo "INSTALL_DIR=install/${{ matrix.qtarch }}" >> $GITHUB_ENV
echo "APK_DIR=$BUILD_DIR/$APK_TARGET/android-build/build/outputs/apk/" >> $GITHUB_ENV
echo "ANDROID_BUILD_DIR=$BUILD_DIR/$APK_TARGET/android-build/" >> $GITHUB_ENV
echo "DEPLOYMENT_SETTINGS=$BUILD_DIR/$APK_TARGET/android-alpineapp-deployment-settings.json" >> $GITHUB_ENV
- name: Configure CMake
env:
CMAKE_PREFIX_PATH: ${{env.QT_ROOT_DIR}}/lib/cmake
run: >
${QT_ROOT_DIR}/bin/qt-cmake
-G Ninja
-B $BUILD_DIR
-DQT_HOST_PATH=${QT_HOST_ROOT_DIR}
-DCMAKE_BUILD_TYPE=Release
-DALP_WWW_INSTALL_DIR=$INSTALL_DIR
-DALP_ENABLE_ASSERTS=ON
-DFMT_INSTALL=OFF
${{ matrix.additional_cmake_flags }}
-S ${{ github.workspace }}
- name: Build
run: cmake --build $BUILD_DIR ${{ matrix.additional_build_flags }}
- name: Signing Android package with common key
env:
secret_test: ${{ secrets.KEYSTOREPASSWORD }}
if: matrix.qttarget == 'android' && env.secret_test != ''
run: |
echo ${{ secrets.SIGNINGKEYBASE64 }} > release.keystore.base64
base64 -d release.keystore.base64 > release.keystore
$QT_HOST_ROOT_DIR/bin/androiddeployqt --input $DEPLOYMENT_SETTINGS --output $ANDROID_BUILD_DIR --android-platform android-35 --gradle --release --sign release.keystore alpinemaps --storepass ${{ secrets.KEYSTOREPASSWORD }}
- name: Signing Android packages with generated key
env:
secret_test: ${{ secrets.KEYSTOREPASSWORD }}
if: matrix.qttarget == 'android' && env.secret_test == ''
run: |
keytool -genkey -v -keystore release.keystore -alias alpinemaps -keyalg RSA -sigalg SHA1withRSA -keysize 2048 -validity 10000 -keypass asdfasdf -storepass asdfasdf -dname "CN=Franz, OU=IT, O=Furz, L=Rattenberg, ST=Tirol, C=AT"
$QT_HOST_ROOT_DIR/bin/androiddeployqt --input $DEPLOYMENT_SETTINGS --output $ANDROID_BUILD_DIR --android-platform android-35 --gradle --release --sign release.keystore alpinemaps --storepass asdfasdf
README_PATH=$APK_DIR/read_me.txt
echo "The apk was signed with a generated key which changes every time the apk is generated. This means, that android might refuse to install it if another apk with the same app was installed previously. You'll have to deinstall it. Doing so will delete all settings and cache." >> $README_PATH
echo "" >> $README_PATH
echo "In order to prevent that, you have to generate your own key or use our public key:" >> $README_PATH
echo "" >> $README_PATH
echo "To generate your own key:" >> $README_PATH
echo "- https://stackoverflow.com/questions/3997748/how-can-i-create-a-keystore. Use 'alpinemaps' as the alias!" >> $README_PATH
echo "- If you have the android dev setup ready in Qt Creator, you can also create the keystore via Projects (on the left side toolboar) -> Android Qt ... -> Build -> Build Steps -> Build Android APK -> Application Signature -> Create. Use 'alpinemaps' as the alias!" >> $README_PATH
echo "- Then you have to encode the keystore in base64, e.g., on linux via 'base64 keystorefile > keystorefile.base64'" >> $README_PATH
echo "- Finally, create the following secrets in github -> your repo -> Settings -> Secrets and variables -> Actions -> Repository secrets" >> $README_PATH
echo " SIGNINGKEYBASE64 = the base64 encoded key" >> $README_PATH
echo " KEYSTOREPASSWORD = the password used to create the keystore" >> $README_PATH
echo "" >> $README_PATH
echo "To use our public key, go to https://github.com/AlpineMapsOrg/renderer/blob/main/creating_apk_keys.md" >> $README_PATH
echo "" >> $README_PATH
echo "Oh, and I hope this saved your day :)" >> $README_PATH
- name: Copy android packages
if: matrix.qttarget == 'android'
run: |
mkdir -p $INSTALL_DIR
cp -r $APK_DIR/* $INSTALL_DIR
- name: Create artifact
uses: actions/upload-artifact@v4
with:
name: files_${{ matrix.qtarch }}
path: ${{ github.workspace }}/install/
if-no-files-found: error
build-wasm:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
config: [wasm_mt, wasm_st]
include:
- config: wasm_mt_lto
qtflags: '-ltcg $(cat $QT_LITE_CONFIG) -feature-thread'
cmakeflags: '-DALP_ENABLE_THREADING=ON -DALP_ENABLE_ASSERTS=OFF'
qtversion: '6.8.1'
webassembly_version: "3.1.56"
- config: wasm_st_lto
qtflags: '-ltcg $(cat $QT_LITE_CONFIG) -no-feature-thread'
cmakeflags: '-DALP_ENABLE_THREADING=OFF -DALP_ENABLE_ASSERTS=OFF'
qtversion: '6.8.1'
webassembly_version: "3.1.56"
- config: wasm_mt
qtflags: '$(cat $QT_LITE_CONFIG) -feature-thread'
cmakeflags: '-DALP_ENABLE_THREADING=ON -DALP_ENABLE_ASSERTS=OFF'
qtversion: '6.8.1'
webassembly_version: "3.1.56"
- config: wasm_st
qtflags: '-$(cat $QT_LITE_CONFIG) -no-feature-thread'
cmakeflags: '-DALP_ENABLE_THREADING=OFF -DALP_ENABLE_ASSERTS=OFF'
qtversion: '6.8.1'
webassembly_version: "3.1.56"
- config: wasm_st_debug
qtflags: '-no-feature-thread'
cmakeflags: '-DALP_ENABLE_THREADING=OFF -DALP_ENABLE_ASSERTS=ON'
qtversion: '6.8.1'
webassembly_version: "3.1.56"
steps:
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y build-essential ninja-build
- uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- uses: mymindstorm/setup-emsdk@v13
with:
version: ${{matrix.webassembly_version}}
- name: Install Qt native version (required for cross building)
uses: jurplel/install-qt-action@v4
with:
aqtversion: '==3.1.*'
version: ${{matrix.qtversion}}
host: linux
target: 'desktop'
arch: linux_gcc_64
dir: '${{github.workspace}}/qt_host'
install-deps: 'true'
modules: 'qtshadertools'
cache: true
- name: Set reusable strings
shell: bash
run: |
echo "BUILD_DIR="$(pwd)/build"" >> $GITHUB_ENV
echo "INSTALL_DIR=install/${{ matrix.config}}" >> $GITHUB_ENV
echo "QT_WASM_ROOT_DIR=$(pwd)/qt_wasm_lite" >> $GITHUB_ENV
echo "QT_SRC_CONFIGURE=$(pwd)/qt_src/configure" >> $GITHUB_ENV
echo "QT_LITE_CONFIG=$(pwd)/misc/qt_lite.txt" >> $GITHUB_ENV
- name: Verify emcc
run: emcc -v
- name: Cache Qt WebAssembly build
id: qt-cache
uses: actions/cache@v4
with:
path: qt_wasm_lite
key: ${{ matrix.config }}_qt-${{ matrix.qtversion }}_emcc-${{ matrix.webassembly_version }}
- name: Download and patch Qt
if: steps.qt-cache.outputs.cache-hit != 'true'
shell: bash
run: |
git clone --branch v${{matrix.qtversion}} git://code.qt.io/qt/qt5.git qt_src
$QT_SRC_CONFIGURE -init-submodules -submodules qtdeclarative,qtbase -skip qtlanguageserver,qtquicktimeline,qtimageformats,qtsvg
cd qt_src/qtbase
git apply ../../misc/qt_68_qtbase_remove_dejavu_fonts.patch
- name: Build Qt for Webassembly (custom version)
if: steps.qt-cache.outputs.cache-hit != 'true'
shell: bash
run: |
dest_dir="${{env.QT_WASM_ROOT_DIR}}"
mkdir qt_wasm_build
cd qt_wasm_build
${{env.QT_SRC_CONFIGURE}} -qt-host-path $QT_ROOT_DIR -release -optimize-size -platform wasm-emscripten -submodules qtdeclarative,qtbase -skip qtlanguageserver,qtquicktimeline,qtimageformats,qtsvg -make libs -gui ${{ matrix.qtflags }} -prefix "${QT_WASM_ROOT_DIR}/"
# cat ./build.ninja
sed -i 's/-flto=thin/-flto/g' ./build.ninja
# echo "=============================================================================================================================================="
# cat ./build.ninja
cmake --build . --parallel && cmake --install .
# Fail if the directory is not created or is empty
[ -d "$QT_WASM_ROOT_DIR" ] && [ "$(ls -A $QT_WASM_ROOT_DIR)" ] || exit 1
- name: Remove StatsWindow, otherwise the webassembly will link against qtwidgets and charts.
run: rm ./app/StatsWindow.qml
- name: Configure
env:
CMAKE_PREFIX_PATH: ${{env.Qt6_DIR}}/lib/cmake
run: >
${QT_WASM_ROOT_DIR}/bin/qt-cmake
-G Ninja
-B $BUILD_DIR
-DCMAKE_BUILD_TYPE=MinSizeRel
-DALP_WWW_INSTALL_DIR=$INSTALL_DIR
-DALP_ENABLE_LTO=ON
-DFMT_INSTALL=OFF
${{ matrix.cmakeflags }}
-S ${{ github.workspace }}
- name: Build
run: cmake --build $BUILD_DIR --target install
- name: Create artifact
uses: actions/upload-artifact@v4
with:
name: files_${{ matrix.config}}
path: ${{ github.workspace }}/install/
if-no-files-found: error
deploy:
if: github.event_name == 'push'
needs:
- build-android
- build-wasm
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Install dependencies
run: sudo apt-get install -y lftp
- name: Clone repository (only for version number)
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: ${{github.workspace}}/downloaded
- name: Move into place
run: |
mkdir $GITHUB_WORKSPACE/github_page
mv $GITHUB_WORKSPACE/downloaded/*/* $GITHUB_WORKSPACE/github_page/
- name: Upload to an FTP host
env:
FTP_USER: ${{ secrets.FTP_USER }}
FTP_PASS: ${{ secrets.FTP_PASS }}
FTP_HOST: ${{ secrets.FTP_HOST }}
if: env.FTP_HOST != ''
run: |
reponame=$(echo $GITHUB_REPOSITORY | grep -oE "[^/]*$")
lftp -c "
set ftp:ssl-force true;
open -u $FTP_USER,$FTP_PASS $FTP_HOST;
mirror -R -e -v -n $GITHUB_WORKSPACE/github_page/. ./${reponame}_$(git describe --tags --dirty=-d --abbrev=1);
"
- name: Fix headers for wasm multithread
run: |
cd $GITHUB_WORKSPACE/github_page/wasm_mt_lto
wget https://raw.githubusercontent.com/gzuidhof/coi-serviceworker/master/coi-serviceworker.min.js
sed -i -e 's#<body onload="init()">#<body onload="init()"><script src="coi-serviceworker\.min\.js"></script>#g' alpineapp.html
cd $GITHUB_WORKSPACE/github_page/wasm_mt
wget https://raw.githubusercontent.com/gzuidhof/coi-serviceworker/master/coi-serviceworker.min.js
sed -i -e 's#<body onload="init()">#<body onload="init()"><script src="coi-serviceworker\.min\.js"></script>#g' alpineapp.html
- name: Generate Directory Listings
uses: jayanta525/[email protected]
with:
FOLDER: github_page
- name: Create Pages artifact
uses: actions/upload-pages-artifact@v3
with:
path: ${{github.workspace}}/github_page
- name: Setup Pages
uses: actions/configure-pages@v4
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4