-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcodemagic.yaml
More file actions
337 lines (313 loc) · 14.5 KB
/
codemagic.yaml
File metadata and controls
337 lines (313 loc) · 14.5 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
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
scripts:
- &get_app_version
name: "Get RIA DigiDoc version"
script: |
echo APP_VERSION=$(xcodebuild -project $CM_BUILD_DIR/RIADigiDoc.xcodeproj -showBuildSettings | grep MARKETING_VERSION | tr -d 'MARKETING_VERSION =') >> $CM_ENV
- &get_google_services_plist
name: "Get Google Services configuration"
script: |
echo $GOOGLE_SERVICES_PLIST | base64 --decode > "$CM_BUILD_DIR/RIADigiDoc/Supporting files/GoogleService-Info.plist"
workflows:
debug:
name: RIA DigiDoc debug
max_build_duration: 30
instance_type: mac_mini_m2
integrations:
app_store_connect: Codemagic MOPP
environment:
ios_signing:
distribution_type: app_store
bundle_identifier: ee.ria.digidoc
groups:
- "google_services"
- "repo_ria"
vars:
BUNDLE_ID: "ee.ria.digidoc"
XCODE_SCHEME: "RIADigiDoc"
APP_STORE_APP_ID: 1216104448
APP_STORE_APPLE_ID: ET847QJV9F
RESOURCES_DIRECTORY: "Modules/ConfigLib/Sources/ConfigLib/Resources"
xcode: latest
inputs:
defaultCentralConfigurationUrl_input:
description: Default Central Configuration URL
type: choice
default: http://10.1.24.31/config/mobile
options:
- http://10.1.24.31/config/mobile
- https://id.eesti.ee
- https://id-test.eesti.ee
- https://id.test.eesti.ee
defaultCentralConfigurationUpdateInterval_input:
description: Default Central Configuration Update Interval
type: number
default: 4
defaultCentralConfigurationTslUrl_input:
description: Default Central Configuration TSL URL
type: choice
default: http://10.1.24.31/tsl/trusted-test-mp.xml
options:
- http://10.1.24.31/tsl/trusted-test-mp.xml
- https://ec.europa.eu/tools/lotl/eu-lotl.xml
- https://open-eid.github.io/test-TL/tl-mp-test-EE.xml
memberTsl_input:
description: TSL member lists
type: string
default: "EE;EE_T"
enableTests_input:
description: Run tests?
type: boolean
default: false
scripts:
- name: Parameters
script: |
echo Default Central Configuration URL: ${{ inputs.defaultCentralConfigurationUrl_input }}
echo Default Central Configuration Update Interval: ${{ inputs.defaultCentralConfigurationUpdateInterval_input }}
echo Default Central Configuration TSL URL: ${{ inputs.defaultCentralConfigurationTslUrl_input }}
echo "TSL member lists: ${{ inputs.memberTsl_input }}"
echo Run tests?: ${{ inputs.enableTests_input }}
- name: Setup dependencies
script: |
brew install swift-sh
curl -L https://github.com/uber/mockolo/releases/download/2.5.0/mockolo.artifactbundle.zip -o mockolo.zip
unzip mockolo.zip
sudo cp mockolo.artifactbundle/mockolo/macos/mockolo /usr/local/bin/mockolo
- *get_google_services_plist
- name: "Setup config and TSL files"
script: |
export CONFIG_DIRECTORY="$RESOURCES_DIRECTORY/config"
export TSL_FILES_DIRECTORY="$RESOURCES_DIRECTORY/tslFiles"
# Create config, TSL folders and mock folders for each module
mkdir -p $CONFIG_DIRECTORY
mkdir -p $TSL_FILES_DIRECTORY
# SPM packages must exist and need at least 1 file. Mock files are generated in 'Run tests' step
for module in CommonsLib ConfigLib CryptoLib IdCardLib LibdigidocLib MobileIdLib SmartIdLib UtilsLib; do
mock_dir="Modules/${module}/Tests/Mocks/Generated"
mkdir -p "$mock_dir"
echo "// Placeholder for generated mocks" > "${mock_dir}/__placeholder.swift"
done
# Remove current files in tslFiles.bundle
echo "Removing current TSL files"
find $TSL_FILES_DIRECTORY -mindepth 1 ! -name ".keep" -delete
# Download latest 'eu-lotl.xml' file"
echo "Downloading latest 'eu-lotl.xml' file"
wget "https://ec.europa.eu/tools/lotl/eu-lotl.xml" -P $TSL_FILES_DIRECTORY
# Get repo.ria values from environmental variables, as CodeMagic doesn't have access to repo.ria domain
if [[ "${{ inputs.defaultCentralConfigurationTslUrl_input }}" == *"10.1.24.31"* ]]; then
echo "Using repo.ria configuration"
echo $REPO_RIA_DEFAULT_PROPERTIES | base64 --decode > $CONFIG_DIRECTORY/configuration.properties
echo $REPO_RIA_CONFIG | base64 --decode > $CONFIG_DIRECTORY/default-config.json
echo $REPO_RIA_PUB_KEY | base64 --decode > $CONFIG_DIRECTORY/default-config.ecpub
echo $REPO_RIA_ECC | base64 --decode > $CONFIG_DIRECTORY/default-config.ecc
echo $REPO_RIA_TRUSTED_TEST_MP | base64 --decode > $TSL_FILES_DIRECTORY/trusted-test-mp.xml
echo $REPO_RIA_TL_MP_TEST_EE | base64 --decode > $TSL_FILES_DIRECTORY/tl-mp-test-EE.xml
# EE_T.xml is too large to use in environmental variable. Using compressed variant
echo $REPO_RIA_EE_T_TSL | base64 --decode | gunzip > $TSL_FILES_DIRECTORY/EE_T.xml
else
echo "Not using repo.ria configuration"
fi
if [ -f "$TSL_FILES_DIRECTORY/eu-lotl.xml" ]; then
echo "Getting TSL (local LOTL)"
# Repo.ria TSL files already in assets folder, doesn't need to download separately anymore
if [[ "${{ inputs.defaultCentralConfigurationTslUrl_input }}" == *"10.1.24.31"* ]]; then
python3 scripts/TSLXMLDownloader.py --tslFile="$TSL_FILES_DIRECTORY/eu-lotl.xml" --countries="${{ inputs.memberTsl_input }}" --isDevBuild="True"
else
python3 scripts/TSLXMLDownloader.py --tslFile="$TSL_FILES_DIRECTORY/eu-lotl.xml" --tslTestFile="$TSL_FILES_DIRECTORY/$(basename ${{ inputs.defaultCentralConfigurationTslUrl_input }})" --countries="${{ inputs.memberTsl_input }}" --isDevBuild="True"
fi
echo "Finished downloading TSL"
else
echo "Getting TSL (remote LOTL)"
python3 scripts/TSLXMLDownloader.py --tslTestFile="$TSL_FILES_DIRECTORY/$(basename 'https://ec.europa.eu/tools/lotl/eu-lotl.xml')" --countries="${{ inputs.memberTsl_input }}" --isDevBuild="True"
echo "Finished downloading TSL"
fi
echo "Moving TSLs to app's TSL files directory"
mv -v scripts/TSL/* $TSL_FILES_DIRECTORY
echo "Done moving TSLs"
- *get_app_version
- name: Fetch default configuration
script: |
# Not running 'SetupConfiguration' for repo.ria as necessary files are already setup
if [[ ! "${{ inputs.defaultCentralConfigurationTslUrl_input }}" == *"10.1.24.31"* ]]; then
echo "Cleaning swift-sh cache"
swift-sh --clean-cache
echo "Fetching default configuration"
swift-sh SetupConfiguration/Sources/main.swift ${{ inputs.defaultCentralConfigurationUrl_input }} ${{ inputs.defaultCentralConfigurationUpdateInterval_input }} ${{ inputs.defaultCentralConfigurationTslUrl_input }}
else
echo "Skipping default configuration fetching for repo.ria"
fi
- name: Set up provisioning profiles settings on Xcode project
script: xcode-project use-profiles
- name: Run tests
script: |
sh scripts/GenerateMocks.sh
sh scripts/run-ci-tests.sh
when:
condition: ${{ inputs.enableTests_input }}
- name: Increment build number
script: |
LATEST_BUILD_NUMBER=$(app-store-connect get-latest-build-number $APP_STORE_APP_ID)
LATEST_BUILD_NUMBER=$((LATEST_BUILD_NUMBER + 1))
echo "LATEST_BUILD_NUMBER=$LATEST_BUILD_NUMBER" >> $CM_ENV
agvtool new-version -all "$LATEST_BUILD_NUMBER"
- name: Build RIA DigiDoc
script: |
# Skip fetching configuration for repo.ria as necessary files are already setup
REPO_RIA_CONF_FLAGS=""
if [[ "${{ inputs.defaultCentralConfigurationTslUrl_input }}" == *"10.1.24.31"* ]]; then
REPO_RIA_CONF_FLAGS="DEFAULT_CENTRAL_CONFIGURATION_URL='' DEFAULT_CENTRAL_CONFIGURATION_UPDATE_INTERVAL=4 DEFAULT_CENTRAL_CONFIGURATION_TSL_URL=''"
fi
# Enable logging flag
LOGGING_FLAGS="OTHER_SWIFT_FLAGS=\"\$(inherited) -DENABLE_LOGGING\""
# Add logging flag to conf flags
ARCHIVE_FLAGS="$REPO_RIA_CONF_FLAGS $LOGGING_FLAGS"
xcode-project build-ipa \
--clean \
--project "$CM_BUILD_DIR/RIADigiDoc.xcodeproj" \
--scheme "$XCODE_SCHEME" \
--archive-xcargs "$ARCHIVE_FLAGS"
- name: Rename and move IPA
script: |
mv -v build/ios/ipa/RIADigiDoc.ipa build/ios/ipa/"RIA_DigiDoc_dev_$APP_VERSION.$LATEST_BUILD_NUMBER.ipa"
- name: Generate release notes for TestFlight
script: |
cat <<EOF > release_notes.json
[
{
"language": "en-GB",
"text": "Branch: $CM_BRANCH \\nMode: dev"
},
{
"language": "en-US",
"text": "Branch: $CM_BRANCH \\nMode: dev"
}
]
EOF
artifacts:
- build/ios/ipa/*.ipa
- /tmp/xcodebuild_logs/*.log
- $HOME/Library/Developer/Xcode/DerivedData/**/Build/**/*.app
- $HOME/Library/Developer/Xcode/DerivedData/**/Build/**/*.dSYM
publishing:
email:
recipients:
- marten.rebane@nortal.com
notify:
success: true
failure: true
app_store_connect:
auth: integration
submit_to_testflight: false
release:
name: RIA DigiDoc release
max_build_duration: 30
instance_type: mac_mini_m2
integrations:
app_store_connect: Codemagic MOPP
environment:
ios_signing:
distribution_type: app_store
bundle_identifier: ee.ria.digidoc
groups:
- "google_services"
vars:
BUNDLE_ID: "ee.ria.digidoc"
XCODE_SCHEME: "RIADigiDoc"
APP_STORE_APP_ID: 1216104448
APP_STORE_APPLE_ID: ET847QJV9F
RESOURCES_DIRECTORY: "Modules/ConfigLib/Sources/ConfigLib/Resources"
xcode: latest
scripts:
- name: Setup dependencies
script: |
brew install swift-sh
curl -L https://github.com/uber/mockolo/releases/download/2.5.0/mockolo.artifactbundle.zip -o mockolo.zip
unzip mockolo.zip
sudo cp mockolo.artifactbundle/mockolo/macos/mockolo /usr/local/bin/mockolo
- *get_google_services_plist
- name: "Setup config and TSL files"
script: |
export CONFIG_DIRECTORY="$RESOURCES_DIRECTORY/config"
export TSL_FILES_DIRECTORY="$CONFIG_DIRECTORY/tslFiles.bundle"
# Create TSL folder and mock folders for each module
mkdir -p $TSL_FILES_DIRECTORY
# SPM packages must exist and need at least 1 file. Mock files are generated in 'Run tests' step
for module in CommonsLib ConfigLib CryptoLib IdCardLib LibdigidocLib MobileIdLib SmartIdLib UtilsLib; do
mock_dir="Modules/${module}/Tests/Mocks/Generated"
mkdir -p "$mock_dir"
echo "// Placeholder for generated mocks" > "${mock_dir}/__placeholder.swift"
done
# Remove current files in tslFiles.bundle
echo "Removing current TSL files"
find $TSL_FILES_DIRECTORY -mindepth 1 ! -name ".keep" -delete
# Download latest 'eu-lotl.xml' file"
echo "Downloading latest 'eu-lotl.xml' file"
wget "https://ec.europa.eu/tools/lotl/eu-lotl.xml" -P $TSL_FILES_DIRECTORY
if [ -f "$TSL_FILES_DIRECTORY/eu-lotl.xml" ]; then
echo "Getting TSL (local LOTL)"
python3 scripts/TSLXMLDownloader.py --tslFile="$TSL_FILES_DIRECTORY/eu-lotl.xml" --tslTestFile="$TSL_FILES_DIRECTORY/$(basename 'https://ec.europa.eu/tools/lotl/eu-lotl.xml')" --countries="EE" --isDevBuild="False"
echo "Finished downloading TSL"
else
echo "Getting TSL (remote LOTL)"
python3 scripts/TSLXMLDownloader.py --tslTestFile="$TSL_FILES_DIRECTORY/$(basename 'https://ec.europa.eu/tools/lotl/eu-lotl.xml')" --countries="EE" --isDevBuild="False"
echo "Finished downloading TSL"
fi
echo "Moving TSLs to app's TSL files directory"
mv -v scripts/TSL/* $TSL_FILES_DIRECTORY
echo "Done moving TSLs"
- name: Fetch default configuration
script: |
echo "Cleaning swift-sh cache"
swift-sh --clean-cache
echo "Fetching default configuration"
swift-sh SetupConfiguration/Sources/main.swift "https://id.eesti.ee" 4 "https://ec.europa.eu/tools/lotl/eu-lotl.xml"
- name: Set up provisioning profiles settings on Xcode project
script: xcode-project use-profiles
- name: Run tests
script: |
sh scripts/GenerateMocks.sh
sh scripts/run-ci-tests.sh
- *get_app_version
- name: Increment build number
script: |
LATEST_BUILD_NUMBER=$(app-store-connect get-latest-build-number $APP_STORE_APP_ID)
LATEST_BUILD_NUMBER=$((LATEST_BUILD_NUMBER + 1))
echo "LATEST_BUILD_NUMBER=$LATEST_BUILD_NUMBER" >> $CM_ENV
agvtool new-version -all "$LATEST_BUILD_NUMBER"
- name: Build RIA DigiDoc
script: |
xcode-project build-ipa \
--clean \
--project "$CM_BUILD_DIR/RIADigiDoc.xcodeproj" \
--scheme "$XCODE_SCHEME"
- name: Rename and move IPA
script: |
mv -v build/ios/ipa/RIADigiDoc.ipa build/ios/ipa/"RIA_DigiDoc_release_$APP_VERSION.$LATEST_BUILD_NUMBER.ipa"
- name: Generate release notes for TestFlight
script: |
cat <<EOF > release_notes.json
[
{
"language": "en-GB",
"text": "Branch: $CM_BRANCH \\nMode: release \\nApp: MOPP3"
},
{
"language": "en-US",
"text": "Branch: $CM_BRANCH \\nMode: release \\nApp: MOPP3"
}
]
EOF
artifacts:
- build/ios/ipa/*.ipa
- /tmp/xcodebuild_logs/*.log
- $HOME/Library/Developer/Xcode/DerivedData/**/Build/**/*.app
- $HOME/Library/Developer/Xcode/DerivedData/**/Build/**/*.dSYM
publishing:
email:
recipients:
- marten.rebane@nortal.com
notify:
success: true
failure: true
app_store_connect:
auth: integration
submit_to_testflight: false