-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbitrise-android.yml
291 lines (252 loc) · 8.65 KB
/
bitrise-android.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
#
# bitrise.yml
# Copyright © 2017 Netguru Sp. z o.o. All rights reserved.
#
# This `bitrise.yml` variant contains the default Android configuration to be
# used in a React Native app repository. You can strip the comments in your
# `bitrise.yml`, if you want.
#
# Scripts in the following `bitrise.yml` file makes use of the following
# environment variables that should be set up as secret:
#
# - `HOCKEYAPP_APP_ID_STAGING`, `HOCKEYAPP_APP_ID_PRODUCTION`: App IDs of
# staging and production HockeyApp apps.
#
# - `HOCKEYAPP_API_TOKEN_STAGING`, `HOCKEYAPP_API_TOKEN_PRODUCTION`: API tokens
# used to upload and release builds to HockeyApp app.
#
# - `SLACK_WEBHOOK_URL`: A generic webhook integration URL used to post
# notifications to Slack.
#
# - `SLACK_CHANNEL` (optional): A target Slack channel to post notifications to.
# If not present, the default channel of the integration is used.
#
# - `JIRA_DOMAIN` (optional): A domain URL to the JIRA installation, typically a
# subdomain on `atlassian.net`. If not present, information about JIRA task
# will not be included in a Slack notification.
#
# - `JIRA_PROJECT_KEY` (optional): A JIRA project key assocciated with the
# repository. If not present, information about JIRA task will not be included
# in a Slack notification.
#
# Also, those scripts use the following environment variables that are declared
# publicly in the following file:
#
# - `GRADLE_BUILD_PATH`: A path to `gradle.build` file to use.
#
# - `GRADLE_W_PATH`: A path to `gradlew` file to use.
#
# - `GRADLE_TASK`: A task to be performed by `gradle` commands.
#
# CLI metadata.
#
# This metadata is required to always be in `bitrise.yml`. The `format_version`
# setting will be occasionally bumped.
format_version: 1.3.1
default_step_lib_source: https://github.com/bitrise-io/bitrise-steplib.git
# Workflow trigger map.
#
# The following trigger map triggers a build only for pull requests against
# `develop` and `master` branches (from forks as well) and pushes to `develop`
# and `master` branches.
#
# More on trigger maps: http://devcenter.bitrise.io/webhooks/trigger-map
trigger_map:
- push_branch: develop
workflow: build-staging
- push_branch: master
workflow: build-release-candidate
- pull_request_target_branch: develop
workflow: build-pull-request
- pull_request_target_branch: master
workflow: build-pull-request
# Environment configuration.
#
# This list contains the default environment variables shared between workflows.
app:
envs:
- GRADLE_BUILD_PATH: ./android/build.gradle
- GRADLE_W_PATH: ./android/gradlew
- GRADLE_TASK: ''
# Workflow declarations.
#
# This list contains workflows used in the above trigger map.
workflows:
# Build, test and deploy a staging app.
#
# This workflow pulls dependencies, builds and tests an app with staging
# scheme and finally pushes the archived build to HockeyApp.
build-staging:
envs:
- GRADLE_TASK: assembleRelease
- HOCKEYAPP_API_TOKEN: $HOCKEYAPP_API_TOKEN_STAGING
- HOCKEYAPP_APP_ID: $HOCKEYAPP_APP_ID_STAGING
before_run:
- cache-pull
- bootstrap-dotenv
- bootstrap-android-sdk
- bootstrap-react-native
- test-react-native
# uncomment this after merging https://github.com/geektimecoil/react-native-onesignal/pull/242
# - test-gradle
- archive-gradle
after_run:
- cache-push
- deploy-hockeyapp
- deploy-bitriseio
- notify-slack
# Build, test and deploy a release candidate app.
#
# This workflow pulls dependencies, builds and tests an app with production
# scheme and finally pushes the archived build to HockeyApp.
build-release-candidate:
envs:
- GRADLE_TASK: assembleRelease
- HOCKEYAPP_API_TOKEN: $HOCKEYAPP_API_TOKEN_PRODUCTION
- HOCKEYAPP_APP_ID: $HOCKEYAPP_APP_ID_PRODUCTION
before_run:
- cache-pull
- bootstrap-dotenv
- bootstrap-android-sdk
- bootstrap-react-native
- test-react-native
# uncomment this after merging https://github.com/geektimecoil/react-native-onesignal/pull/242
# - test-gradle
- archive-gradle
after_run:
- cache-push
- deploy-hockeyapp
- deploy-bitriseio
- notify-slack
# Build and test a staging app.
#
# This workflow pulls dependencies and then builds and tests an app with
# staging scheme.
build-pull-request:
envs:
- GRADLE_TASK: assembleDebug
before_run:
- cache-pull
- bootstrap-dotenv
- bootstrap-android-sdk
- bootstrap-react-native
- test-react-native
# uncomment this after merging https://github.com/geektimecoil/react-native-onesignal/pull/242
# - test-gradle
after_run:
- cache-push
- deploy-bitriseio
- notify-slack
# Pull previously cached directories.
cache-pull:
steps:
- cache-pull: {}
# Push cached directories.
#
# By default, this pushes `./gradle`, `~/.gradle` and `./node_modules`
# directories.
cache-push:
steps:
- cache-push:
inputs:
- cache_paths: |-
$HOME/.gradle
./.gradle
./node_modules
- ignore_check_on_paths: |-
$HOME/.gradle/caches/*.lock
./.gradle/*.lock
./.gradle/*.bin
# Bootstrap `.env` file by cloning `.env.bitrise` file and then assigning the
# appropriate values from environment variables set up in this `bitrise.yml`
# and in Bitrise UI.
bootstrap-dotenv:
steps:
- ruby-script:
inputs:
- ruby_content: |-
template = ENV['DOTENV_TEMPLATE_FILE'] || '.env.bitrise'
output_file = ENV['DOTENV_OUTPUT_FILE'] || '.env'
File.open(output_file, 'w') do |output|
File.open(template).each do |line|
output.write(line.sub(/\$[A-Z0-9_]+/) { |match| ENV[match.sub('$', '')] })
end
end
# Install additional Android packages.
bootstrap-android-sdk:
steps:
- script:
title: update-android-sdk
inputs:
- content: |-
set -ex
echo y | android update sdk --no-ui --all --filter build-tools-23.0.1 | grep 'package installed'
echo y | android update sdk --no-ui --all --filter platform-tools | grep 'package installed'
echo y | android update sdk --no-ui --all --filter extra-android-m2repository | grep 'package installed'
echo y | android update sdk --no-ui --all --filter extra-google-m2repository | grep 'package installed'
echo y | android update sdk --no-ui --all --filter extra-google-google_play_services | grep 'package installed'
# Bootstrap React Native dependencies using NVM and Yarn package managers.
bootstrap-react-native:
steps:
- nvm: {}
- yarn: {}
- install-react-native: {}
# Bootstrap code signing by installing certificates and provisioning profiles.
bootstrap-code-signing:
steps:
- certificate-and-profile-installer: {}
# Bundle and test an app using `react-native` and `npm` commands.
test-react-native:
steps:
- react-native-bundle:
inputs:
- platform: android
- entry_file: index.android.js
# - yarn:
# inputs:
# - command: lint
- yarn:
inputs:
- command: test
# Test and assemble an app using `gradle` command.
test-gradle:
steps:
- gradle-unit-test:
inputs:
- gradle_file: $GRADLE_BUILD_PATH
- gradlew_file_path: $GRADLE_W_PATH
# Assemble and code sign an app using `gradle` command.
archive-gradle:
steps:
- gradle-runner:
inputs:
- gradle_file: $GRADLE_BUILD_PATH
- gradlew_path: $GRADLE_W_PATH
- gradle_task: $GRADLE_TASK
- sign-apk: {}
# Deploy a built app to HockeyApp.
deploy-hockeyapp:
steps:
- hockeyapp-deploy-android:
inputs:
- api_token: $HOCKEYAPP_API_TOKEN
- app_id: $HOCKEYAPP_APP_ID
- apk_path: $BITRISE_SIGNED_APK_PATH
- notify: 0
# Deploy build artifacts to bitrise.io.
deploy-bitriseio:
steps:
- deploy-to-bitrise-io:
inputs:
- notify_user_groups: none
- is_enable_public_page: false
# Notify about build on Slack.
#
# If you don't use Slack integration, you can remove this workflow.
notify-slack:
steps:
- git::https://github.com/netguru/bitrise-step-slack.git@master:
title: slack
inputs:
- webhook_url: $SLACK_WEBHOOK_URL
- channel: $SLACK_CHANNEL