-
Notifications
You must be signed in to change notification settings - Fork 33
264 lines (263 loc) · 10.4 KB
/
fastlane_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
name: Fastlane Android
on:
workflow_call:
inputs:
tag:
type: string
description: Build a specific git tag
required: true
instance:
type: string
required: false
instance_url:
type: string
required: false
default: ""
app_name:
type: string
required: false
default: "CoopCycle"
primary_color:
type: string
required: false
default: ""
package_name:
type: string
required: false
default: "fr.coopcycle"
keystore_key_alias:
type: string
required: false
default: "coopcycle"
keystore_key_password_secret:
type: string
required: false
default: "SIGNING_KEY_PASSWORD"
google_play_track:
type: string
required: false
default: "internal"
deploy_google_play:
type: boolean
required: false
default: true
app_auth_redirect_scheme:
type: string
required: false
default: "fr.coopcycle.oauth"
jobs:
FASTLANE:
name: Release Android app with Fastlane
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: ${{ inputs.tag }}
- uses: actions/setup-node@v4
with:
node-version: '20.x'
cache: 'yarn'
- uses: ruby/setup-ruby@v1
with:
ruby-version: '3.1'
- uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
cache: 'gradle'
- uses: mfinelli/setup-imagemagick@v5
- name: Find Metro cache
id: metro-cache-dir-path
uses: actions/github-script@v4
with:
result-encoding: string
script: |
const os = require('os');
const path = require('path');
return path.join(os.tmpdir(), 'metro-cache');
- name: Restore Metro cache
uses: actions/cache@v3
with:
path: ${{ steps.metro-cache-dir-path.outputs.result }}
key: ${{ runner.os }}-metro-cache-${{ github.ref }}
restore-keys: |
${{ runner.os }}-metro-cache-${{ github.base_ref }}
${{ runner.os }}-metro-cache-
- name: Sets env vars for build
run: |
echo "FASTLANE_CMD=build" >> $GITHUB_ENV
if: ${{ ! inputs.deploy_google_play }}
- name: Sets env vars for deploy
run: |
echo "FASTLANE_CMD=deploy" >> $GITHUB_ENV
if: ${{ inputs.deploy_google_play }}
- name: Create .env file
env:
SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
DATADOG_CLIENT_TOKEN: ${{ secrets.DATADOG_CLIENT_TOKEN }}
DATADOG_APPLICATION_ID: ${{ secrets.DATADOG_APPLICATION_ID }}
GOOGLE_MAPS_BROWSER_KEY: ${{ secrets.GOOGLE_MAPS_BROWSER_KEY }}
GOOGLE_MAPS_ANDROID_KEY: ${{ secrets.GOOGLE_MAPS_ANDROID_KEY }}
TRANSISTORSOFT_LICENSE_KEY: ${{ secrets.TRANSISTORSOFT_LICENSE_KEY }}
FACEBOOK_APP_ID: ${{ secrets.FACEBOOK_APP_ID }}
GOOGLE_SIGN_IN_CLIENT_ID: ${{ secrets.GOOGLE_SIGN_IN_CLIENT_ID }}
DEFAULT_SERVER: ${{ inputs.instance_url }}
PRIMARY_COLOR: ${{ inputs.primary_color }}
SMARTLOOK_PROJECT_KEY: ${{ secrets.SMARTLOOK_PROJECT_KEY }}
FACEBOOK_CLIENT_TOKEN: ${{ secrets.FACEBOOK_CLIENT_TOKEN }}
APP_AUTH_REDIRECT_SCHEME: ${{ inputs.app_auth_redirect_scheme }}
run: |
touch .env
echo COUNTLY_SERVER_URL= >> .env
echo COUNTLY_APP_KEY= >> .env
echo COUNTLY_SALT= >> .env
echo SENTRY_DSN="$SENTRY_DSN" >> .env
echo DATADOG_ENABLED="1" >> .env
echo DATADOG_CLIENT_TOKEN="$DATADOG_CLIENT_TOKEN" >> .env
echo DATADOG_APPLICATION_ID="$DATADOG_APPLICATION_ID" >> .env
echo GOOGLE_MAPS_BROWSER_KEY="$GOOGLE_MAPS_BROWSER_KEY" >> .env
echo GOOGLE_MAPS_ANDROID_KEY="$GOOGLE_MAPS_ANDROID_KEY" >> .env
echo TRANSISTORSOFT_LICENSE_KEY="$TRANSISTORSOFT_LICENSE_KEY" >> .env
echo FACEBOOK_APP_ID="$FACEBOOK_APP_ID" >> .env
echo FACEBOOK_CLIENT_TOKEN="$FACEBOOK_CLIENT_TOKEN" >> .env
echo GOOGLE_SIGN_IN_CLIENT_ID="$GOOGLE_SIGN_IN_CLIENT_ID" >> .env
echo DEFAULT_SERVER="$DEFAULT_SERVER" >> .env
echo PRIMARY_COLOR="$PRIMARY_COLOR" >> .env
echo CHECKOUT_SEARCH_ENABLED="$CHECKOUT_SEARCH_ENABLED" >> .env
echo SMARTLOOK_PROJECT_KEY="$SMARTLOOK_PROJECT_KEY" >> .env
echo APP_AUTH_REDIRECT_SCHEME="$APP_AUTH_REDIRECT_SCHEME" >> .env
- name: Decode sentry.properties file
uses: timheuer/[email protected]
with:
fileDir: "./android/"
fileName: "sentry.properties"
encodedString: ${{ secrets.SENTRY_PROPERTIES_BASE64 }}
- name: Decode Android keystore file
uses: timheuer/[email protected]
id: android_keystore
with:
fileName: "android_keystore.kjs"
encodedString: ${{ secrets.SIGNING_STORE_FILE_BASE64 }}
- name: Decode google-services.json file
uses: timheuer/[email protected]
with:
fileDir: "./android/app/"
fileName: "google-services.json"
encodedString: ${{ secrets.GOOGLE_SERVICES_JSON_BASE64 }}
- name: Decode play-store-credentials.json file
uses: timheuer/[email protected]
id: android_play_store_credentials
with:
fileName: "play-store-credentials.json"
encodedString: ${{ secrets.GOOGLE_JSON_KEY_FILE_BASE64 }}
- name: Install RubyGems
working-directory: android/
run: bundle install
- name: Install latest yarn binary
run: yarn set version latest --yarn-path
- name: yarn install
run: yarn install --no-progress --network-timeout 100000 --network-concurrency 1
- name: Run Fastlane
working-directory: android/
run: bundle exec fastlane ${{env.FASTLANE_CMD}}
env:
ANDROID_STORE_FILE: ${{ steps.android_keystore.outputs.filePath }}
ANDROID_STORE_PASSWORD: ${{ secrets.SIGNING_STORE_PASSWORD }}
ANDROID_KEY_ALIAS: ${{ inputs.keystore_key_alias }}
ANDROID_KEY_PASSWORD: ${{ secrets[inputs.keystore_key_password_secret] }}
ANDROID_JSON_KEY_FILE: ${{ steps.android_play_store_credentials.outputs.filePath }}
APPICON_IMAGE_FILE: "fastlane/metadata-${{ inputs.instance }}/app_icon.png"
SUPPLY_PACKAGE_NAME: ${{ inputs.package_name }}
SUPPLY_TRACK: ${{ inputs.google_play_track }}
COOPCYCLE_APP_NAME: ${{ inputs.app_name }}
- name: Move official build
if: '!cancelled()'
run: mv android/app/build/outputs/bundle/**/*.aab release.aab
- name: Upload aab artifact
if: '!cancelled()'
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.app_name }}_release.aab
path: release.aab
AAB_TO_APK:
name: Convert aab to apk
if: '!cancelled()'
needs: FASTLANE
runs-on: ubuntu-latest
steps:
- name: Download a single artifact
uses: actions/download-artifact@v4
with:
name: ${{ inputs.app_name }}_release.aab
- name: Convert aab to apk
id: convert_aab
uses: mukeshsolanki/[email protected]
with:
aabFile: release.aab
base64Keystore: ${{ secrets.SIGNING_STORE_FILE_BASE64 }}
keystorePassword: ${{ secrets.SIGNING_STORE_PASSWORD }}
keystoreAlias: ${{ inputs.keystore_key_alias }}
keyPassword: ${{ secrets[inputs.keystore_key_password_secret] }}
- uses: actions/upload-artifact@v4
with:
name: ${{ inputs.app_name }}-release.apk
path: ${{ steps.convert_aab.outputs.apkPath }}
SCREENSHOTS:
name: Capture screenshots
if: false # '!cancelled()'
needs: AAB_TO_APK
runs-on: macOS-latest
strategy:
matrix:
EMULATOR_API: [28, 33]
EMULATOR_ARCH: [x86_64]
steps:
- uses: actions/checkout@v3
with:
ref: ${{ inputs.tag }}
- name: Download apk artifact
uses: actions/download-artifact@v4
with:
name: release.apk
- name: Install Maestro CLI
run: |
curl -Ls "https://get.maestro.mobile.dev" | bash
export PATH="$PATH":"$HOME/.maestro/bin"
- name: Execute emulator tests
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ matrix.EMULATOR_API }}
target: google_apis
arch: ${{ matrix.EMULATOR_ARCH }}
profile: Nexus 6
# https://github.com/wix/Detox/blob/master/docs/Introduction.AndroidEmulatorsBestPractices.md#booting-an-emulator-via-command-line
emulator-options: -verbose -no-window -no-snapshot -noaudio -no-boot-anim -gpu swiftshader_indirect -camera-back emulated -camera-front emulated
disable-animations: true
script: |
bash -c "echo 'hw.lcd.height=2560' >> /Users/runner/.android/avd/test.avd/config.ini"
bash -c "echo 'hw.lcd.width=1440' >> /Users/runner/.android/avd/test.avd/config.ini"
curl -Ls "https://get.maestro.mobile.dev" | bash
adb root
adb install -t release.apk
adb shell settings put global sysui_demo_allowed 1
adb shell am broadcast -a com.android.systemui.demo -e command clock -e hhmm 1200
adb shell am broadcast -a com.android.systemui.demo -e command network -e mobile show -e level 4 -e datatype 4g -e wifi false
adb shell am broadcast -a com.android.systemui.demo -e command notifications -e visible false
adb shell am broadcast -a com.android.systemui.demo -e command battery -e plugged false -e level 100
$HOME/.maestro/bin/maestro test -e APP_ID=${{ inputs.package_name }} --include-tags=screenshots ./__maestro__
- name: Upload to S3 bucket
uses: Noelware/[email protected]
with:
directories: |
./*.png
access-key-id: ${{ secrets.AWS_KEY_ID }}
path-format: '/$(tag)'
secret-key: ${{ secrets.AWS_SECRET_ACCESS_KEY}}
endpoint: https://s3.fr-par.scw.cloud
prefix: /screenshots/${{ inputs.app_name }}/android-${{ matrix.EMULATOR_ARCH }}
region: fr-par
bucket: coopcycle-ci
- uses: actions/upload-artifact@v4
with:
name: maestro-error-rapport
path: ~/.maestro/tests/