This repository has been archived by the owner on Jul 24, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bitrise.yml
344 lines (341 loc) · 9.53 KB
/
bitrise.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
---
format_version: '5'
default_step_lib_source: https://github.com/bitrise-io/bitrise-steplib.git
project_type: ionic
app:
envs:
- MATCH_READONLY: false
- RUN_IONIC_BUILD_CI: true
- SLACK_CHANNEL: onlytech
trigger_map:
- push_branch: release/*
workflow: builds
- push_branch: "develop"
workflow: dev-debug
- push_branch: "*"
workflow: ci
- pull_request_source_branch: "*"
workflow: ci
- tag: v*.*.*-beta*
workflow: staging
- tag: v*.*.*
workflow: prod
workflows:
_prepare:
steps:
- activate-ssh-key@4.0.3:
run_if: '{{getenv "SSH_RSA_PRIVATE_KEY" | ne ""}}'
- git-clone@4.0.14: {}
- cache-pull: {}
- npm@1.0.1:
inputs:
- version: $NPM_VERSION
- command: install
- script:
run_if: .IsCI
inputs:
- content: |
#!/bin/bash
printf "$GIT_CLONE_COMMIT_MESSAGE_SUBJECT\n$GIT_CLONE_COMMIT_MESSAGE_BODY" | npm run commitlint
ci:
before_run:
- _prepare
steps:
- npm@1.0.1:
inputs:
- version: $NPM_VERSION
- command: 'run lint'
- npm@1.0.1:
run_if: '{{getenv "RUN_IONIC_BUILD_CI"}}'
inputs:
- version: $NPM_VERSION
- command: 'run build'
_fastlane:
steps:
- script:
run_if: |-
{{if getenv "$BITRISE_DEFAULT_PROVISION_URL" | ne ""}}
false
{{else}}
true
{{end}}
inputs:
- content: |
#!/bin/bash
set -e
fastlane certificates --verbose
_build:
before_run:
- ci
- _fastlane
steps:
- script:
inputs:
- content: |
#!/bin/bash
set -e
sudo gem install cocoapods fastlane
pod repo update
brew install gradle
- npm@1.0.1:
inputs:
- version: $NPM_VERSION
- command: 'run ionic:build --enableLint false --prod'
- script:
inputs:
- content: |
#!/bin/bash
# fail if any commands fails
set -e
# debug log
set -x
cmdAndroid="npx ionic cordova build android --no-build --$BUILD_TYPE"
cmdIos="npx ionic cordova build ios --device --no-build --$BUILD_TYPE"
npm run clean-cordova-platforms
$cmdAndroid && $cmdIos
cp ${BITRISE_SOURCE_DIR}/platforms/android/app/build/outputs/apk/$BUILD_TYPE/app-$BUILD_TYPE.apk ${BITRISE_DEPLOY_DIR}/app-$BUILD_TYPE.apk
cp ${BITRISE_SOURCE_DIR}/platforms/ios/build/device/*.ipa ${BITRISE_DEPLOY_DIR}/app-$BUILD_TYPE.ipa
envman add --key BITRISE_APK_PATH --value ${BITRISE_DEPLOY_DIR}/app-$BUILD_TYPE.apk
envman add --key BITRISE_IPA_PATH --value ${BITRISE_DEPLOY_DIR}/app-$BUILD_TYPE.ipa
# var fastlane deliver upload iOS
envman add --key DELIVER_IPA_PATH --value ${BITRISE_DEPLOY_DIR}/app-$BUILD_TYPE.ipa
- cache-push@2.0.5:
inputs:
- cache_paths: |-
./node_modules
$HOME/.gradle
./plugins/
$HOME/Library/Developer/Xcode/DerivedData
- ignore_check_on_paths: |-
$HOME/.gradle/caches/*.lock
$HOME/Library/Developer/Xcode/DerivedData
_deploy:
steps:
- deploy-to-bitrise-io@1.3.19:
inputs:
- is_enable_public_page: false
after_run:
- _hockeyapp-android
- _hockeyapp-ios
_deploy-dev:
steps:
- deploy-to-bitrise-io@1.3.19: {}
- script:
inputs:
- content: |
#!/bin/bash
urls=$BITRISE_PUBLIC_INSTALL_PAGE_URL_MAP
link1=${urls%|*}
link2=${urls#*|}
if [[ $link2 =~ ".apk" ]]; then
linkApk=${link2#*=>}
linkIpa=${link1#*=>}
else
linkApk=${link1#*=>}
linkIpa=${link2#*=>}
fi
envman add --key LINK_APK --value $linkApk
envman add --key LINK_IPA --value $linkIpa
after_run:
- _install-slack-android
- _install-slack-ios
_install-slack:
steps:
- create-install-page-qr-code@1.0.0: {}
- slack@3.1.2:
inputs:
- channel: "$SLACK_CHANNEL"
- api_token: $SLACK_API_TOKEN
- image_url: "$BITRISE_PUBLIC_INSTALL_PAGE_QR_CODE_IMAGE_URL"
- title_link: "$BITRISE_PUBLIC_INSTALL_PAGE_URL"
- fields: |
App|${BITRISE_APP_TITLE}
Platforma|${PLATFORM}
Branch|${BITRISE_GIT_BRANCH}
Workflow|${BITRISE_TRIGGERED_WORKFLOW_ID}
- buttons: |
View App|${BITRISE_APP_URL}
View Build|${BITRISE_BUILD_URL}
Install Page|${BITRISE_PUBLIC_INSTALL_PAGE_URL}
_hockeyapp-ios:
after_run:
- _install-slack-ios
steps:
- hockeyapp-deploy:
inputs:
- api_token: "$FL_HOCKEY_API_TOKEN"
- app_id: "$FL_HOCKEY_APP_ID_IOS"
- script:
inputs:
- title: "Set public url iOS"
- content: |
#!/bin/bash
envman add --key LINK_IPA --value $HOCKEYAPP_DEPLOY_PUBLIC_URL
_hockeyapp-android:
after_run:
- _install-slack-android
steps:
- hockeyapp-deploy-android:
inputs:
- api_token: "$FL_HOCKEY_API_TOKEN"
- app_id: "$FL_HOCKEY_APP_ID_ANDROID"
- script:
inputs:
- title: "Set public url Android"
- content: |
#!/bin/bash
envman add --key LINK_APK --value $HOCKEYAPP_DEPLOY_PUBLIC_URL
_install-slack-android:
envs:
- BITRISE_PUBLIC_INSTALL_PAGE_URL: $LINK_APK
- PLATFORM: Android
after_run:
- _install-slack
_install-slack-ios:
envs:
- BITRISE_PUBLIC_INSTALL_PAGE_URL: $LINK_IPA
- PLATFORM: iOS
after_run:
- _install-slack
_deploy-store:
steps:
- deploy-to-bitrise-io@1.3.19:
inputs:
- is_enable_public_page: false
after_run:
- _google-play
- _apple-store
_google-play:
steps:
- google-play-deploy@1.5.1:
run_if: '{{getenv "BITRISEIO_SERVICE_ACCOUNT_JSON_KEY_URL" | ne ""}}'
inputs:
- package_name: "$APP_IDENTIFIER"
- track: internal
- service_account_json_key_path: "$BITRISEIO_SERVICE_ACCOUNT_JSON_KEY_URL"
_apple-store:
steps:
- script:
inputs:
- title: "Upload Apple Store"
- content: |
#!/bin/bash
set -e
fastlane ios store
_set-env-vars-file:
steps:
- script:
inputs:
- title: "Set env vars file"
- content: |
#!/bin/bash
if [ -n "$ENV_FILE" ]; then
# specify local download path
file_local_path=$BITRISE_SOURCE_DIR/file_env
# download the file
wget -O "$file_local_path" "$ENV_FILE"
filename="$file_local_path"
# set vars define by env file in generic file storage
while IFS= read -r var
do
if [[ $var =~ "=" ]]; then
key=${var%%=*}
value=${var#*=}
valueDefault=${!key}
if [ -n "$value" ] && [ -z "$valueDefault" ]; then
envman add --key $key --value $value
fi
fi
done < "$filename"
fi
_set-env-vars-scope:
steps:
- script:
inputs:
- title: "Set env vars scope"
- content: |
#!/bin/bash
# set variables by scope
# ex: PRODUCTION_MATCH_TYPE, PRODUCTION_NG2_MY_SECRET
if [ -n "$ENV" ]; then
printenv | while read var;
do
if [[ $var =~ "=" ]]; then
key=${var%%=*}
value=${var#*=}
length=${#ENV}
prefix=${key:0:$length+1}
if [ "$prefix" == "${ENV}_" ]; then
key=${key:$length+1}
envman add --key $key --value $value
fi
fi
done
fi
_build-env:
envs:
- RUN_IONIC_BUILD_CI: false
before_run:
- _set-env-vars-file
- _set-env-vars-scope
after_run:
- _build
_debug:
envs:
- APP_VERSION: "${BITRISE_BUILD_NUMBER}-${BITRISE_TRIGGERED_WORKFLOW_ID}"
- BUILD_TYPE: debug
- MATCH_TYPE: development
after_run:
- _build-env
- _deploy-dev
dev-debug:
envs:
- ENV_FILE: $BITRISEIO_ENV_FILE_DEV_URL
after_run:
- _debug
dev:
envs:
- ENV_FILE: $BITRISEIO_ENV_FILE_DEV_URL
- ENV: DEV
- APP_VERSION: "${BITRISE_BUILD_NUMBER}-${BITRISE_TRIGGERED_WORKFLOW_ID}"
- BUILD_TYPE: release
- MATCH_TYPE: enterprise
after_run:
- _build-env
- _deploy
staging:
envs:
- ENV_FILE: $BITRISEIO_ENV_FILE_STAGING_URL
- ENV: STAGING
- APP_VERSION: "${BITRISE_BUILD_NUMBER}-${BITRISE_TRIGGERED_WORKFLOW_ID}"
- BUILD_TYPE: release
- MATCH_TYPE: enterprise
after_run:
- _build-env
- _deploy
prod:
envs:
- ENV_FILE: $BITRISEIO_ENV_FILE_PROD_URL
- ENV: PROD
- BUILD_TYPE: release
steps:
- script:
inputs:
- title: "Set APP version"
- content: |
#!/bin/bash
tagName=${BITRISE_GIT_TAG:1}
envman add --key APP_VERSION --value ${tagName}
after_run:
- _build-env
- _deploy-store
builds:
steps:
- trigger-bitrise-workflow@0.0.4:
inputs:
- workflow_id: dev
- api_token: "$API_TOKEN"
- trigger-bitrise-workflow@0.0.4:
inputs:
- workflow_id: staging
- api_token: "$API_TOKEN"