forked from Expensify/App
-
Notifications
You must be signed in to change notification settings - Fork 0
206 lines (183 loc) · 7.35 KB
/
buildAndroid.yml
File metadata and controls
206 lines (183 loc) · 7.35 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
name: Build Android app
on:
workflow_call:
inputs:
type:
description: 'What type of build to run. Must be one of ["release", "adhoc", "e2e", "e2eDelta"]'
type: string
required: true
ref:
description: Git ref to checkout and build
type: string
required: true
artifact-prefix:
description: 'The prefix for build artifact names. This is useful if you need to call multiple builds from the same workflow'
type: string
required: false
default: ''
pull_request_number:
description: The pull request number associated with this build, if relevant.
type: string
required: false
outputs:
AAB_FILE_NAME:
description: Name of the AAB file produced by this workflow.
value: ${{ jobs.build.outputs.AAB_FILE_NAME }}
APK_FILE_NAME:
description: Name of the APK file produced by this workflow.
value: ${{ jobs.build.outputs.APK_FILE_NAME }}
APK_ARTIFACT_NAME:
description: Name of the APK artifact.
value: ${{ jobs.build.outputs.APK_ARTIFACT_NAME }}
workflow_dispatch:
inputs:
type:
description: What type of build do you want to run?
required: true
type: choice
options:
- release
- adhoc
- e2e
- e2eDelta
ref:
description: Git ref to checkout and build
required: true
type: string
pull_request_number:
description: The pull request number associated with this build, if relevant.
type: number
required: false
jobs:
build:
name: Build Android app
runs-on: ubuntu-latest-xl
outputs:
AAB_FILE_NAME: ${{ steps.build.outputs.AAB_FILE_NAME }}
APK_FILE_NAME: ${{ steps.build.outputs.APK_FILE_NAME }}
APK_ARTIFACT_NAME: ${{ steps.build.outputs.APK_ARTIFACT_NAME }}
steps:
- name: Checkout
# v4
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608
with:
ref: ${{ inputs.ref }}
- name: Configure MapBox SDK
run: ./scripts/setup-mapbox-sdk.sh ${{ secrets.MAPBOX_SDK_DOWNLOAD_TOKEN }}
- name: Setup Node
uses: ./.github/actions/composite/setupNode
- name: Setup Java
# v4
uses: actions/setup-java@3a4f6e1af504cf6a31855fa899c6aa5355ba6c12
with:
distribution: oracle
java-version: 17
- name: Setup Gradle
# v4
uses: gradle/actions/setup-gradle@06832c7b30a0129d7fb559bcc6e43d26f6374244
- name: Setup Ruby
# v1.229.0
uses: ruby/setup-ruby@354a1ad156761f5ee2b7b13fa8e09943a5e8d252
with:
bundler-cache: true
- name: Install 1Password CLI
# v1
uses: 1password/install-cli-action@143a85f84a90555d121cde2ff5872e393a47ab9f
- name: Load files from 1Password
working-directory: android/app
env:
OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}
run: op read "op://${{ vars.OP_VAULT }}/New Expensify my-upload-key.keystore/my-upload-key.keystore" --force --out-file ./my-upload-key.keystore
- name: Get package version
id: getPackageVersion
run: echo "VERSION=$(jq -r .version < package.json)" >> "$GITHUB_OUTPUT"
- name: Get Android native version
id: getAndroidVersion
run: echo "VERSION_CODE=$(grep -o 'versionCode\s\+[0-9]\+' android/app/build.gradle | awk '{ print $2 }')" >> "$GITHUB_OUTPUT"
- name: Setup DotEnv
if: ${{ inputs.type != 'release' }}
run: |
if [ '${{ inputs.type }}' == 'adhoc' ]; then
cp .env.staging .env.adhoc
sed -i 's/ENVIRONMENT=staging/ENVIRONMENT=adhoc/' .env.adhoc
echo "PULL_REQUEST_NUMBER=${{ inputs.pull_request_number }}" >> .env.adhoc
else
envFile=''
if [ '${{ inputs.type }}' == 'e2e' ]; then
envFile='tests/e2e/.env.e2e'
else
envFile=tests/e2e/.env.e2edelta
fi
{
echo "EXPENSIFY_PARTNER_NAME=${{ secrets.EXPENSIFY_PARTNER_NAME }}"
echo "EXPENSIFY_PARTNER_PASSWORD=${{ secrets.EXPENSIFY_PARTNER_PASSWORD }}"
echo "EXPENSIFY_PARTNER_USER_ID=${{ secrets.EXPENSIFY_PARTNER_USER_ID }}"
echo "EXPENSIFY_PARTNER_USER_SECRET=${{ secrets.EXPENSIFY_PARTNER_USER_SECRET }}"
echo "EXPENSIFY_PARTNER_PASSWORD_EMAIL=${{ secrets.EXPENSIFY_PARTNER_PASSWORD_EMAIL }}"
} >> "$envFile"
fi
- name: Build Android app (retryable)
# v3
uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08
id: build
env:
MYAPP_UPLOAD_STORE_PASSWORD: ${{ secrets.MYAPP_UPLOAD_STORE_PASSWORD }}
MYAPP_UPLOAD_KEY_PASSWORD: ${{ secrets.MYAPP_UPLOAD_KEY_PASSWORD }}
with:
retry_on: error
retry_wait_seconds: 60
timeout_minutes: 60
max_attempts: 3
command: |
lane=''
case '${{ inputs.type }}' in
'release')
lane='build';;
'adhoc')
lane='build_adhoc';;
'e2e')
lane='build_e2e';;
'e2eDelta')
lane='build_e2eDelta';;
esac
bundle exec fastlane android "$lane"
# Refresh environment variables from GITHUB_ENV that are updated when running fastlane
# shellcheck disable=SC1090
source "$GITHUB_ENV"
SHOULD_UPLOAD_SOURCEMAPS='false'
if [ -f ./android/app/build/generated/sourcemaps/react/productionRelease/index.android.bundle.map ]; then
SHOULD_UPLOAD_SOURCEMAPS='true'
fi
{
# aabPath and apkPath are environment varibles set within the Fastfile
echo "AAB_PATH=$aabPath"
echo "AAB_FILE_NAME=$(basename "$aabPath")"
echo "APK_PATH=$apkPath"
echo "APK_FILE_NAME=$(basename "$apkPath")"
echo "SHOULD_UPLOAD_SOURCEMAPS=$SHOULD_UPLOAD_SOURCEMAPS"
echo "APK_ARTIFACT_NAME=${{ inputs.artifact-prefix }}android-apk-artifact" >> "$GITHUB_OUTPUT"
} >> "$GITHUB_OUTPUT"
- name: Upload Android AAB artifact
if: ${{ steps.build.outputs.AAB_PATH != '' }}
continue-on-error: true
# v4
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
with:
name: ${{ inputs.artifact-prefix }}android-aab-artifact
path: ${{ steps.build.outputs.AAB_PATH }}
- name: Upload Android APK artifact
if: ${{ steps.build.outputs.APK_PATH != '' }}
continue-on-error: true
# v4
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
with:
name: ${{ steps.build.outputs.APK_ARTIFACT_NAME }}
path: ${{ steps.build.outputs.APK_PATH }}
- name: Upload Android sourcemaps artifact
if: ${{ steps.build.outputs.SHOULD_UPLOAD_SOURCEMAPS == 'true' }}
continue-on-error: true
# v4
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
with:
name: ${{ inputs.artifact-prefix }}android-sourcemaps-artifact
path: ./android/app/build/generated/sourcemaps/react/productionRelease/index.android.bundle.map