forked from emericg/QmlAppTemplate
-
Notifications
You must be signed in to change notification settings - Fork 0
277 lines (245 loc) · 11.4 KB
/
builds_mobile_cmake.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
#-------------------------------------------------------------------------------
# Workflow configuration
#-------------------------------------------------------------------------------
name: "Mobile CI builds (cmake)"
on:
push:
pull_request:
workflow_dispatch:
#-------------------------------------------------------------------------------
# Define application name & version
#-------------------------------------------------------------------------------
env:
APP_NAME: "QmlAppTemplate"
APP_VERSION: "0.6"
QT_VERSION: "6.6.2"
#-------------------------------------------------------------------------------
# SECRETS
#-------------------------------------------------------------------------------
# convert to base64 (linux) : cat file.keystore | base64 | tr -d '\n' > file.base64
# convert to base64 (apple) : cat file.keystore | base64 | tr -d '\n' > file.base64
## Android secrets:
# create a keystore file, convert it to base64
# save the keystore base64 file under the name ANDROID_SIGNINGKEY_BASE64
# save the keystore alias under the name ANDROID_SIGNINGKEY_ALIAS
# save the keystore password under the name ANDROID_SIGNINGKEY_PASSWORD
## Android upload:
# - https://developers.google.com/android-publisher/getting_started
# - https://github.com/fastlane/fastlane/blob/master/fastlane/lib/fastlane/actions/docs/upload_to_play_store.md
# create the gplay service account, download the json key, convert it to base64
# save the base64 under the name GPLAY_SERVICEACCOUNTKEY_BASE64
## Apple secrets:
# - https://developer.apple.com/help/account/reference/certificate-types
# - https://docs.github.com/en/actions/deployment/deploying-xcode-applications/installing-an-apple-certificate-on-macos-runners-for-xcode-development
# a valid apple developer account is required
# create a build certificate with xcode, download it, convert it to base64
# save the build certificate base64 file under the name APPLE_BUILD_CERTIFICATE_BASE64
# save the build certificate password under the name APPLE_BUILD_CERTIFICATE_PASSWORD
# create a provisioning profile for your app bundle id, download it, convert it to base64
# save the provisioning profile under the name APPLE_PROVISIONING_PROFILE_BASE64
# a new keychain will be created on the runner to store these certificates, choose a new password under the name APPLE_KEYCHAIN_PASSWORD
## iOS upload:
# TODO
#-------------------------------------------------------------------------------
# Workflow jobs
#-------------------------------------------------------------------------------
jobs:
## Android build #############################################################
build-android:
name: "Android CI build"
runs-on: ubuntu-20.04
steps:
# Checkout repository (and submodules)
- name: Checkout repository (and submodules)
uses: actions/checkout@v4
with:
submodules: recursive
# Java environment (already installed in 'ubuntu-20.04')
- name: Setup Java environment
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
# Android environment (already installed in 'ubuntu-20.04')
#- name: Setup Android environment
# uses: android-actions/setup-android@v3
#- name: Install Android SDK / NDK / tools
# run: |
# sdkmanager "platforms;android-34"
# sdkmanager "ndk;25.2.9519653"
# sdkmanager "build-tools;34.0.0"
# Install Qt (desktop & Android)
- name: Install Qt (desktop)
uses: jurplel/install-qt-action@v3
with:
aqtversion: '==3.1.*'
version: ${{env.QT_VERSION}}
modules: qt5compat
- name: Install Qt (Android armv7)
uses: jurplel/install-qt-action@v3
with:
aqtversion: '==3.1.*'
version: ${{env.QT_VERSION}}
host: 'linux'
target: 'android'
arch: 'android_armv7'
modules: qt5compat
- name: Install Qt (Android armv8)
uses: jurplel/install-qt-action@v3
with:
aqtversion: '==3.1.*'
version: ${{env.QT_VERSION}}
host: 'linux'
target: 'android'
arch: 'android_arm64_v8a'
modules: qt5compat
- name: Install Qt (Android x86)
uses: jurplel/install-qt-action@v3
with:
aqtversion: '==3.1.*'
version: ${{env.QT_VERSION}}
host: 'linux'
target: 'android'
arch: 'android_x86'
modules: qt5compat
- name: Install Qt (Android x86_64)
uses: jurplel/install-qt-action@v3
with:
aqtversion: '==3.1.*'
version: ${{env.QT_VERSION}}
host: 'linux'
target: 'android'
arch: 'android_x86_64'
modules: qt5compat
# Install dependencies (from package manager)
- name: Install dependencies (from package manager)
run: |
sudo apt-get install cmake ninja-build -y;
# Setup env
- name: Setup env
run: |
echo "QT_HOST_PATH=/home/runner/work/${{env.APP_NAME}}/Qt/${{env.QT_VERSION}}/gcc_64" >> $GITHUB_ENV
echo "QT_TARGET_PATH=/home/runner/work/${{env.APP_NAME}}/Qt/${{env.QT_VERSION}}/android_arm64_v8a" >> $GITHUB_ENV
# Build application
- name: Build application
run: |
cmake --version
cmake -B build/ -G Ninja \
-DCMAKE_SYSTEM_NAME=Android \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_FIND_ROOT_PATH:PATH=${{env.QT_TARGET_PATH}} \
-DCMAKE_PREFIX_PATH:PATH=${{env.QT_TARGET_PATH}} \
-DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK_ROOT/build/cmake/android.toolchain.cmake \
-DANDROID_SDK_ROOT=$ANDROID_SDK_ROOT \
-DANDROID_NDK_ROOT=$ANDROID_NDK_ROOT \
-DANDROID_PLATFORM=android-23 \
-DANDROID_ABI="arm64-v8a" \
-DQT_HOST_PATH:PATH=${{env.QT_HOST_PATH}} \
-DQT_ANDROID_BUILD_ALL_ABIS=ON \
-DQT_ANDROID_ABIS="armeabi-v7a;arm64-v8a;x86;x86_64"
cmake --build build/ --config Release
# Package & sign application
- name: Package & sign application
env:
secret_test: ${{ secrets.ANDROID_SIGNINGKEY_ALIAS }}
if: env.secret_test != ''
run: |
echo ${{ secrets.ANDROID_SIGNINGKEY_BASE64 }} > release.keystore.base64
base64 -d release.keystore.base64 > release.keystore
${{env.QT_HOST_PATH}}/bin/androiddeployqt --input build/android-${{env.APP_NAME}}-deployment-settings.json --output build/android-build/ --android-platform android-34 --aab --release --sign release.keystore ${{ secrets.ANDROID_SIGNINGKEY_ALIAS }} --storepass ${{ secrets.ANDROID_SIGNINGKEY_PASSWORD }}
# Upload Android app bundle (GitHub CI)
- name: Upload Android app bundle (GitHub CI)
uses: actions/upload-artifact@v4
with:
name: ${{env.APP_NAME}}-${{env.APP_VERSION}}-Android.aab
path: build/android-build/build/outputs/bundle/release/android-build-release.aab
# Upload Android app bundle (Play Store)
- name: Upload Android app bundle (Play Store)
run: |
echo ${{ secrets.GPLAY_SERVICEACCOUNTKEY_BASE64 }} > assets/android/fastlane/gplay_serviceaccountkey.base64
base64 -d assets/android/fastlane/gplay_serviceaccountkey.base64 > assets/android/fastlane/gplay_serviceaccountkey.json
mv assets/android/fastlane/ fastlane/
fastlane android deploy
## iOS build #################################################################
build-ios:
name: "iOS CI build"
runs-on: macos-12
steps:
# Checkout repository (and submodules)
- name: Checkout repository (and submodules)
uses: actions/checkout@v4
with:
submodules: recursive
# Install Qt (desktop)
- name: Install Qt (desktop)
uses: jurplel/install-qt-action@v3
with:
version: ${{env.QT_VERSION}}
modules: qt5compat qtshadertools
# Install Qt (iOS)
- name: Install Qt (iOS)
uses: jurplel/install-qt-action@v3
with:
version: ${{env.QT_VERSION}}
modules: qt5compat qtshadertools
host: 'mac'
target: 'ios'
# Install dependencies (from package manager)
#- name: Install dependencies (from package manager)
# run: |
# brew install cmake
# Setup env
- name: Setup env
run: |
echo "QT_HOST_PATH=/Users/runner/work/${{env.APP_NAME}}/Qt/${{env.QT_VERSION}}/macos" >> $GITHUB_ENV
echo "QT_TARGET_PATH=/Users/runner/work/${{env.APP_NAME}}/Qt/${{env.QT_VERSION}}/ios" >> $GITHUB_ENV
# Setup developer certificate and provisioning profile
- name: Setup developer certificate and provisioning profile
env:
APPLE_BUILD_CERTIFICATE_BASE64: ${{ secrets.APPLE_BUILD_CERTIFICATE_BASE64 }}
APPLE_BUILD_CERTIFICATE_PASSWORD: ${{ secrets.APPLE_BUILD_CERTIFICATE_PASSWORD }}
APPLE_PROVISIONING_PROFILE_BASE64: ${{ secrets.APPLE_PROVISIONING_PROFILE_BASE64 }}
APPLE_KEYCHAIN_PASSWORD: ${{ secrets.APPLE_KEYCHAIN_PASSWORD }}
run: |
# create variables
CERT_PATH=$RUNNER_TEMP/build_certificate.p12
PP_PATH=$RUNNER_TEMP/build_pp.mobileprovision # .mobileprovision for iOS # .provisionprofile for macOS
KEYCHAIN_PATH=$RUNNER_TEMP/app-signing.keychain-db
# import certificate and provisioning profile from secrets
echo -n "$APPLE_BUILD_CERTIFICATE_BASE64" | base64 --decode -o $CERT_PATH
echo -n "$APPLE_PROVISIONING_PROFILE_BASE64" | base64 --decode -o $PP_PATH
# create temporary keychain
security create-keychain -p "$APPLE_KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
security set-keychain-settings -lut 21600 $KEYCHAIN_PATH
security unlock-keychain -p "$APPLE_KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
# import certificate to keychain
security import $CERT_PATH -P "$APPLE_BUILD_CERTIFICATE_PASSWORD" -A -t cert -f pkcs12 -k $KEYCHAIN_PATH
security list-keychain -d user -s $KEYCHAIN_PATH
# apply provisioning profile
mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles
cp $PP_PATH ~/Library/MobileDevice/Provisioning\ Profiles
# Build application
- name: Build application
run: |
cmake --version
cmake -B build/ -G Xcode \
-DCMAKE_SYSTEM_NAME=iOS \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_FIND_ROOT_PATH:PATH=${{env.QT_TARGET_PATH}} \
-DCMAKE_PREFIX_PATH:PATH=${{env.QT_TARGET_PATH}} \
-DCMAKE_TOOLCHAIN_FILE=assets/ios/ios.toolchain.cmake \
-DQT_HOST_PATH:PATH=${{env.QT_HOST_PATH}} \
-DENABLE_ARC=FALSE \
-DPLATFORM=OS64 \
-DCMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED="YES" \
-DCMAKE_XCODE_ATTRIBUTE_CODE_SIGN_STYLE="Manual" \
-DCMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY="iPhone Developer" \
-DCMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM="24Q8SM98H5" \
-DCMAKE_XCODE_ATTRIBUTE_PROVISIONING_PROFILE="a8ac7ee1-5f4e-4e9c-a0f2-be05df16c179"
cmake --build build/ --config Release
# Recap stuff
- name: Recap stuff
continue-on-error: true
run: |
ls build/
ls build/Release-iphoneos