forked from MerginMaps/mobile
-
Notifications
You must be signed in to change notification settings - Fork 1
267 lines (234 loc) · 10.8 KB
/
ios.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
name: iOS Build
on:
push:
paths:
- 'app/**'
- 'core/**'
- 'images/**'
- 'qgsquick/**'
- 'scripts/**'
- '.github/workflows/ios.yml'
release:
types:
- published
env:
QT_VERSION: 5.14.2
INPUT_SDK_VERSION: ios-20220212-36
IOS_PROVISIONING_PROFILE_UUID: 59aaa8d7-516a-4592-8c58-d7d1c1f81610
KEYCHAIN: ${{ 'inputapp.keychain' }}
XC_VERSION: ${{ '12.0.1' }}
IOS_MIN_SDK_VERSION: ${{ '12.0' }}
CCACHE_DIR: /Users/runner/work/ccache
CACHE_VERSION: 2
concurrency:
group: ci-${{github.ref}}-ios
cancel-in-progress: true
jobs:
ios_build:
if: ( github.repository == 'lutraconsulting/input' ) && (!contains(github.event.head_commit.message, 'Translate '))
runs-on: macos-10.15
steps:
- name: Select latest Xcode
run: "sudo xcode-select -s /Applications/Xcode_$XC_VERSION.app"
- uses: actions/checkout@v2
# CCache
- name: Prepare build cache for pull request
uses: pat-s/always-upload-cache@v2.1.5
if: github.event_name == 'pull_request'
with:
path: ${{ env.CCACHE_DIR }}
key: build-ios-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-ios-ccache-${{ github.actor }}-${{ github.head_ref }}-
build-ios-ccache-refs/heads/${{ github.base_ref }}-
build-ios-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/always-upload-cache@v2.1.5
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-ios-ccache-${{ github.ref }}-${{ github.sha }}
restore-keys: |
build-ios-ccache-${{ github.ref }}-
build-ios-ccache-refs/heads/master-
- name: Install brew deps
run: |
brew install gnupg
brew install openssl@1.1
brew install python3
brew install ccache
- name: Install ccache
run: |
mkdir -p ${CCACHE_DIR}
ccache --set-config=max_size=2.0G
ccache -s
- name: Extract Mergin API_KEY
env:
MERGINSECRETS_DECRYPT_KEY: ${{ secrets.MERGINSECRETS_DECRYPT_KEY }}
run: |
cd core/
/usr/local/opt/openssl@1.1/bin/openssl \
aes-256-cbc -d \
-in merginsecrets.cpp.enc \
-out merginsecrets.cpp \
-k "$MERGINSECRETS_DECRYPT_KEY" \
-md md5
- name: Configure Keychain
run: |
security create-keychain -p "" "$KEYCHAIN"
security list-keychains -s "$KEYCHAIN"
security default-keychain -s "$KEYCHAIN"
security unlock-keychain -p "" "$KEYCHAIN"
security set-keychain-settings
security list-keychains
- name: Configure Code Signing
env:
IOS_GPG_KEY: ${{ secrets.IOS_GPG_KEY }}
IOS_CERT_KEY: ${{ secrets.IOS_CERT_KEY }}
run: |
gpg --quiet --batch --yes --decrypt --passphrase="$IOS_GPG_KEY" --output ./.github/secrets/ios/Certificates_ios_dist.p12 ./.github/secrets/ios/Certificates_ios_dist.p12.gpg
security import "./.github/secrets/ios/Certificates_ios_dist.p12" -k "$KEYCHAIN" -P "$IOS_CERT_KEY" -A
security set-key-partition-list -S apple-tool:,apple: -s -k "" "$KEYCHAIN"
mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles
gpg --quiet --batch --yes --decrypt --passphrase="$IOS_GPG_KEY" --output ./.github/secrets/ios/LutraConsultingLtdInputAppStore.mobileprovision ./.github/secrets/ios/LutraConsultingLtdInputAppStore.mobileprovision.gpg
cp ./.github/secrets/ios/LutraConsultingLtdInputAppStore.mobileprovision ~/Library/MobileDevice/Provisioning\ Profiles/${IOS_PROVISIONING_PROFILE_UUID}.mobileprovision
# Input SDK
- name: Cache Input-SDK
id: cache-input-sdk
uses: pat-s/always-upload-cache@v2.1.5
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 \
${{ github.workspace }}/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
# Qt
- name: Cache Qt
id: cache-qt
uses: pat-s/always-upload-cache@v2.1.5
with:
path: ${{ github.workspace }}/Qt
key: ${{ runner.os }}-QtCache-${{ env.QT_VERSION }}-ios-${{ env.CACHE_VERSION }}
- name: Install Qt
uses: jurplel/install-qt-action@v2
with:
version: ${{ env.QT_VERSION }}
target: ios
dir: ${{ github.workspace }}
cached: ${{ steps.cache-qt.outputs.cache-hit }}
# Do this only until we move from 5.14.2!!
- name: Patch Qt!
shell: bash
run: |
echo "Patch 5.14.2 see https://github.com/lutraconsulting/input-sdk/issues/34"
if [ ! ${{ env.QT_VERSION }} == "5.14.2" ]; then
echo "Can not patch other Qt version than 5.14.2. Remove this step in case of higher Qt version!"
exit 1
fi
cp ${{ github.workspace }}/scripts/ci/ios/toolchain5.14.2_xcode12.prf ${{ github.workspace }}/Qt/${{ env.QT_VERSION }}/ios/mkspecs/features/toolchain.prf
# Build Input App
# !! ccache_clang is a custom script which runs ccache and default XCode clang.
# !! It has been created due to a bug in Qt when QMAKE_CXX ignored everything after
# !! whitespace chars. In that case in the string 'ccache clang++' clang was ignored
# !! and ccache received all of the compilation flags that were supposed to go to clang.
- name: Export app/config.pri
shell: bash
run: |
touch ./app/config.pri
echo -e "ios {" >> ./app/config.pri
echo -e " INPUT_SDK_PATH=${{ github.workspace }}/input-sdk/arm64" >> ./app/config.pri
echo -e " QGIS_QUICK_DATA_PATH = INPUT" >> ./app/config.pri
echo -e " QMAKE_IOS_DEPLOYMENT_TARGET = ${{ env.IOS_MIN_SDK_VERSION }}" >> ./app/config.pri
echo -e " QMAKE_CXX = ${{ github.workspace }}/scripts/ci/ios/ccache_clang" >> ./app/config.pri
echo -e "}" >> ./app/config.pri
cat ./app/config.pri
if [ ! ${{ env.QT_VERSION }} == "5.14.2" ]; then
echo "Qt version has changed! Double check if we still need custom script 'ccache_clang' for QMAKE_CXX."
echo " - If yes, change this condition to the new Qt version"
echo " - If no, remove the 'ccache_clang' script and this check too"
exit 1
fi
# Parse Input-SDK version run number - it is used as middle integer in version number in CF_BUNDLE_VERSION
- name: Parse SDK version run number
uses: rishabhgupta/split-by@v1
id: split
with:
string: ${{ env.INPUT_SDK_VERSION }}
split-by: '-'
- name: Create build system with qmake
run: |
INPUT_DIR=`pwd`
# patch the Info.plist
CF_BUNDLE_SHORT_VERSION=`/usr/libexec/PlistBuddy -c "Print :CFBundleShortVersionString" $INPUT_DIR/app/ios/Info.plist`
TIMESTAMP=`date "+%y%m%d%H%M%S"`
GIT_BRANCH_NAME=`git rev-parse --abbrev-ref HEAD`
BRANCH_NUMBER=`if [ "X$GIT_BRANCH_NAME" == "Xmaster" ]; then echo "2"; else echo "1"; fi`
CF_BUNDLE_VERSION=${BRANCH_NUMBER}.${{ steps.split.outputs._2 }}.${TIMESTAMP}
echo "Building version: $CF_BUNDLE_VERSION"
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $CF_BUNDLE_VERSION" "$INPUT_DIR/app/ios/Info.plist"
mkdir -p build-INPUT
cd build-INPUT
# run qmake
${{ github.workspace }}/Qt/${{ env.QT_VERSION }}/ios/bin/qmake \
${INPUT_DIR}/app/input.pro \
-spec macx-ios-clang \
CONFIG+=release \
CONFIG+=iphoneos \
CONFIG+=device \
CONFIG+=qtquickcompiler \
QMAKE_MAC_XCODE_SETTINGS+=qprofile \
qprofile.name=PROVISIONING_PROFILE_SPECIFIER \
qprofile.value="LutraConsultingLtd.Input.AppStore" \
QMAKE_MAC_XCODE_SETTINGS+=qteam \
qteam.name=DEVELOPMENT_TEAM \
qteam.value=79QMH2QRAH \
QMAKE_MAC_XCODE_SETTINGS+=qidentity \
qidentity.name=CODE_SIGN_IDENTITY \
qidentity.value="iPhone Distribution: LUTRA CONSULTING LIMITED (79QMH2QRAH)" \
QMAKE_MAC_XCODE_SETTINGS+=qstyle \
qstyle.name=CODE_SIGN_STYLE \
qstyle.value=Manual
- name: Build Input
run: |
INPUT_DIR=`pwd`
cd build-INPUT
xcodebuild \
-project Input.xcodeproj/ \
-scheme Input \
-sdk iphoneos \
-configuration Release \
archive -archivePath Input.xcarchive \
"OTHER_CODE_SIGN_FLAGS=--keychain '$KEYCHAIN'"
- name: Create Input Package
run: |
INPUT_DIR=`pwd`
cd build-INPUT
xcodebuild \
-archivePath Input.xcarchive \
-exportOptionsPlist $INPUT_DIR/scripts/ci/ios/exportOptions.plist \
-exportPath $PWD \
-allowProvisioningUpdates \
-exportArchive
- name: Upload .ipa to TestFlight
env:
INPUTAPP_BOT_APPLEID_PASS: ${{ secrets.INPUTAPP_BOT_APPLEID_PASS }}
INPUTAPP_BOT_APPLEID_USER: ${{ secrets.INPUTAPP_BOT_APPLEID_USER }}
INPUTAPP_BOT_GITHUB_TOKEN: ${{ secrets.INPUTAPP_BOT_GITHUB_TOKEN }}
if: success()
run: |
CF_BUNDLE_VERSION=`/usr/libexec/PlistBuddy -c "Print :CFBundleVersion" app/ios/Info.plist`
echo "Publishing ios ${CF_BUNDLE_VERSION}"
xcrun altool --upload-app -t ios -f build-INPUT/Input.ipa -u "$INPUTAPP_BOT_APPLEID_USER" -p "$INPUTAPP_BOT_APPLEID_PASS" --verbose
# Add comment to GitHub
GITHUB_API=https://api.github.com/repos/lutraconsulting/input/commits/${GITHUB_SHA}/comments
curl -u inputapp-bot:${INPUTAPP_BOT_GITHUB_TOKEN} -X POST --data '{"body": "iOS - version '${CF_BUNDLE_VERSION}' just submitted!"}' ${GITHUB_API}