-
Notifications
You must be signed in to change notification settings - Fork 33
227 lines (188 loc) · 7.54 KB
/
build-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
name: Android
on:
workflow_call:
inputs:
environment:
required: true
type: string
branch:
required: true
type: string
jobs:
android:
name: Build
runs-on: ubuntu-latest
environment: client-${{ inputs.environment }}
env:
CI: github
SOURCEMAPS_DIR: ./build/sourcemaps
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_ORG: ${{ vars.SENTRY_ORG }}
SENTRY_PROJECT: ${{ vars.SENTRY_PROJECT }}
DOTENV_ENVIRONMENT: ${{ vars.ENVIRONMENT }}
DOTENV_DEBUG: ${{ vars.DEBUG }}
DOTENV_ANDROID_CODE_PUSH_DEPLOYMENT_KEY: ${{ vars.ANDROID_CODE_PUSH_DEPLOYMENT_KEY }}
DOTENV_ANDROID_PACKAGE_NAME: ${{ vars.ANDROID_PACKAGE_NAME }}
DOTENV_API_ENDPOINT: ${{ vars.API_ENDPOINT }}
DOTENV_DEEP_LINK_PREFIX: ${{ vars.DEEP_LINK_PREFIX }}
DOTENV_DEEP_LINK_SCHEME: ${{ vars.DEEP_LINK_SCHEME }}
DOTENV_IOS_APPSTORE_ID: ${{ vars.IOS_APPSTORE_ID }}
DOTENV_IOS_CODE_PUSH_DEPLOYMENT_KEY: ${{ vars.IOS_CODE_PUSH_DEPLOYMENT_KEY }}
DOTENV_METRICS_ENDPOINT: ${{ vars.METRICS_ENDPOINT }}
DOTENV_POSTHOG_API_KEY: ${{ vars.POSTHOG_API_KEY }}
DOTENV_SENTRY_DSN: ${{ vars.SENTRY_DSN }}
DOTENV_STORAGE_ENDPOINT: ${{ vars.STORAGE_ENDPOINT }}
DOTENV_STRIPE_APPLE_MERCHANT_IDENTIFIER: ${{ vars.STRIPE_APPLE_MERCHANT_IDENTIFIER }}
DOTENV_STRIPE_PUBLISHABLE_KEY: ${{ vars.STRIPE_PUBLISHABLE_KEY }}
ANDROID_PACKAGE_NAME: ${{ vars.ANDROID_PACKAGE_NAME }}
ANDROID_FLAVOR: ${{ vars.ANDROID_FLAVOR }}
ANDROID_UPLOAD_STORE_PASSWORD: ${{ secrets.ANDROID_UPLOAD_STORE_PASSWORD }}
ANDROID_UPLOAD_KEY_PASSWORD: ${{ secrets.ANDROID_UPLOAD_KEY_PASSWORD }}
ANDROID_GOOGLE_PLAY_SERVICE_FILE: ./google-play-service.json
steps:
- uses: actions/checkout@v3
with:
lfs: 'true'
- name: Use Java 17
uses: actions/setup-java@v4
with:
java-version: 17
distribution: zulu
cache: gradle
- name: Use Ruby 2.7.2
uses: ruby/setup-ruby@v1
with:
ruby-version: 2.7.2
- name: Use Node.js v18.18
uses: actions/setup-node@v3
with:
node-version: 18.18
- name: Create Dotenv File
uses: iamsauravsharma/[email protected]
with:
env-prefix: DOTENV_
directory: ./client
- name: Create google-play-service.json
working-directory: ./client
run: |
cat > $ANDROID_GOOGLE_PLAY_SERVICE_FILE << EOL
${{ secrets.ANDROID_GOOGLE_PLAY_SERVICE_FILE }}
EOL
- name: Create google-services.json
working-directory: ./client/android/app/src
run: |
cat > ./$ANDROID_FLAVOR/google-services.json << EOL
${{ secrets.ANDROID_GOOGLE_SERVICES_FILE }}
EOL
- name: Create release.keystore
working-directory: ./client/android/app
run: echo -n "${{ secrets.ANDROID_RELEASE_KEYSTORE }}" | base64 --decode > release.keystore
- name: Prepare Source Maps Directory
working-directory: ./client
run: mkdir -p $SOURCEMAPS_DIR
- name: Prepare $GIT_COMMIT_SHORT
working-directory: ./shared
run: ./scripts/getGitCommitShort.sh >> $GITHUB_ENV
- name: Cache Shared Dependencies
id: cache-shared-node-modules
uses: actions/cache@v2
with:
path: ./shared/node_modules
key: shared-node-modules-${{ hashFiles('./shared/yarn.lock') }}
- name: Install Shared Dependencies
if: steps.cache-shared-node-modules.outputs.cache-hit != 'true'
working-directory: ./shared
run: yarn
- name: Cache Content Dependencies
id: cache-content-node-modules
uses: actions/cache@v2
with:
path: ./content/node_modules
key: content-node-modules-${{ hashFiles('./content/yarn.lock') }}
- name: Install Content Dependencies
if: steps.cache-content-node-modules.outputs.cache-hit != 'true'
working-directory: ./content
run: yarn
- name: Cache Client Dependencies
id: cache-client-node-modules
uses: actions/cache@v2
with:
path: ./client/node_modules
key: client-node-modules-${{ hashFiles('./client/yarn.lock') }}
- name: Install Client Dependencies
if: steps.cache-client-node-modules.outputs.cache-hit != 'true'
working-directory: ./client
run: yarn
- name: Install Fastlane Dependencies
working-directory: ./client/fastlane
run: bundle install
- name: Build Content
working-directory: ./content
run: yarn build
- name: Build & Upload App
working-directory: ./client/fastlane
env:
RUBYOPT: '-rostruct' # TODO: Remove when https://github.com/fastlane/fastlane/pull/21950 gets released
run: bundle exec fastlane android app
- name: Upload AAB
uses: actions/upload-artifact@v3
if: always()
with:
name: android-aab
path: ./client/android/app/build/outputs/bundle
- name: Upload Logs
uses: actions/upload-artifact@v3
if: failure()
with:
name: android-build-logs
path: ./client/android/app/build/outputs/logs
- name: Generate Source Map
working-directory: ./client
run: >
yarn react-native bundle
--dev false
--entry-file index.js
--platform android
--bundle-output $SOURCEMAPS_DIR/index.android.bundle
--sourcemap-output $SOURCEMAPS_DIR/index.android.bundle.map
- name: Compile Hermes Bytecode
working-directory: ./client
run: >
node_modules/react-native/sdks/hermesc/linux64-bin/hermesc
-O -emit-binary
-output-source-map
-out=$SOURCEMAPS_DIR/index.android.bundle.hbc
$SOURCEMAPS_DIR/index.android.bundle
rm -f $SOURCEMAPS_DIR/index.android.bundle
mv $SOURCEMAPS_DIR/index.android.bundle.hbc $SOURCEMAPS_DIR/index.android.bundle
- name: Compose Hermes Bytecode and Source Map
working-directory: ./client
run: >
mv $SOURCEMAPS_DIR/index.android.bundle.map $SOURCEMAPS_DIR/index.android.bundle.packager.map
node node_modules/react-native/scripts/compose-source-maps.js
$SOURCEMAPS_DIR/index.android.bundle.packager.map
$SOURCEMAPS_DIR/index.android.bundle.hbc.map
-o $SOURCEMAPS_DIR/index.android.bundle.map
node node_modules/@sentry/react-native/scripts/copy-debugid.js
$SOURCEMAPS_DIR/index.android.bundle.packager.map
$SOURCEMAPS_DIR/index.android.bundle.map
rm -f $SOURCEMAPS_DIR/index.android.bundle.packager.map
- name: Upload Source Map to Sentry
working-directory: ./client
run: >
yarn sentry-cli sourcemaps upload
--debug-id-reference
--strip-prefix $PWD
--dist ${{ vars.ENVIRONMENT }}
--release $GIT_COMMIT_SHORT
$SOURCEMAPS_DIR/index.android.bundle
$SOURCEMAPS_DIR/index.android.bundle.map
- name: Associate Commits to Sentry Release
working-directory: ./client
run: yarn sentry-cli releases set-commits --auto $GIT_COMMIT_SHORT
- name: Create Pull Request
uses: peter-evans/create-pull-request@v6
with:
title: Android native version bump on ${{ inputs.branch }} (auto generated)
commit-message: Native Version Bump
branch: ${{ inputs.branch }}-android-native-version-bump