forked from Expensify/App
-
Notifications
You must be signed in to change notification settings - Fork 1
189 lines (167 loc) · 6.57 KB
/
buildAndroid.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
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:
value: ${{ jobs.build.outputs.AAB_FILE_NAME }}
APK_FILE_NAME:
value: ${{ jobs.build.outputs.APK_FILE_NAME }}
APK_ARTIFACT_NAME:
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
uses: actions/checkout@v4
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
uses: actions/setup-java@v4
with:
distribution: oracle
java-version: 17
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
- name: Setup Ruby
uses: ruby/[email protected]
with:
bundler-cache: true
- name: Decrypt keystore to sign the APK/AAB
run: gpg --batch --yes --decrypt --passphrase="${{ secrets.LARGE_SECRET_PASSPHRASE }}" --output my-upload-key.keystore my-upload-key.keystore.gpg
working-directory: android/app
- 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)
uses: nick-fields/retry@v3
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
uses: actions/upload-artifact@v4
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
uses: actions/upload-artifact@v4
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
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.artifact-prefix }}android-sourcemaps-artifact
path: ./android/app/build/generated/sourcemaps/react/productionRelease/index.android.bundle.map