Repository navigation
173 lines (148 loc) · 6.44 KB
/
Copy pathe2e-build-android.yml
File metadata and controls
173 lines (148 loc) · 6.44 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
name: E2E Build Android
on:
workflow_call:
secrets:
KEYSTORE_OFFICIAL_BASE64:
required: true
KEYSTORE_OFFICIAL_PASSWORD:
required: true
KEYSTORE_OFFICIAL_ALIAS:
required: true
BUGSNAG_KEY_OFFICIAL:
required: true
inputs:
seed-only:
description: Build only to save a native build under a new fingerprint; no APK artifact
type: boolean
default: false
permissions: {}
jobs:
native-fingerprint:
runs-on: ubuntu-latest
permissions:
contents: read
outputs:
cache-key: ${{ steps.fingerprint.outputs.cache-key }}
cache-hit: ${{ steps.fingerprint.outputs.cache-hit }}
steps:
- name: Checkout Repository
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
- name: Checkout and Setup Node
uses: ./.github/actions/setup-node
- name: Native fingerprint
id: fingerprint
uses: ./.github/actions/native-fingerprint
with:
platform: android
cache-key-prefix: e2e-android-${{ hashFiles('.github/workflows/e2e-build-android.yml') }}
android-build:
needs: native-fingerprint
if: ${{ !(inputs.seed-only && needs.native-fingerprint.outputs.cache-hit == 'true') }}
runs-on: ubuntu-latest
permissions:
contents: read
env:
APK_PATH: android/app/build/outputs/apk/release/app-release.apk
REACT_RES_DIR: android/app/build/generated/res/react/release
outputs:
artifact_name: Android APK
steps:
- name: Checkout Repository
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
- parallel:
- name: Checkout and Setup Node
uses: ./.github/actions/setup-node
- name: Restore cached native build
id: native-cache
uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
with:
path: .native-cache
key: ${{ needs.native-fingerprint.outputs.cache-key }}
- name: Set up JDK
uses: actions/setup-java@c1e323688fd81a25caa38c78aa6df2d33d3e20d9 # v4.8.0
with:
java-version: '17'
distribution: 'temurin'
- name: Setup Android SDK
uses: android-actions/setup-android@9fc6c4e9069bf8d3d10b2204b1fb8f6ef7065407 # v3.2.2
with:
packages: '' # the default `tools` package was removed from the SDK repository
- name: Cache Gradle dependencies
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
with:
path: |
~/.gradle
key: gradle-${{ runner.os }}-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
gradle-${{ runner.os }}-
- name: Set up Gradle
uses: gradle/actions/setup-gradle@ed408507eac070d1f99cc633dbcf757c94c7933a # v4.4.3
with:
gradle-version: wrapper
- name: Decode Keystore
run: |
echo "${{ secrets.KEYSTORE_OFFICIAL_BASE64 }}" | base64 -d > android/app/release.keystore
- name: Swap JS bundle into cached APK
id: swap
if: ${{ steps.native-cache.outputs.cache-hit == 'true' }}
run: |
(cd android && ./gradlew :app:createBundleReleaseJsAndAssets --no-daemon --stacktrace)
if [ "$(cat .native-cache/react-res.sha256)" != "$(.github/scripts/hash-dir.sh "$REACT_RES_DIR")" ]; then
echo "JS-required images differ from the cached build: full native build." >> "$GITHUB_STEP_SUMMARY"
exit 0
fi
mkdir -p "$(dirname "$APK_PATH")"
.github/scripts/swap-android-bundle.sh .native-cache/app-release.apk android/app/build/generated/assets/react/release/index.android.bundle "$APK_PATH"
echo "swapped=true" >> "$GITHUB_OUTPUT"
env:
RUNNING_E2E_TESTS: true
KEYSTORE_PATH: android/app/release.keystore
KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_OFFICIAL_PASSWORD }}
KEY_ALIAS: ${{ secrets.KEYSTORE_OFFICIAL_ALIAS }}
KEY_PASSWORD: ${{ secrets.KEYSTORE_OFFICIAL_PASSWORD }}
- name: Cache Android build
if: ${{ steps.swap.outputs.swapped != 'true' }}
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
with:
path: |
android/.gradle
android/app/build
android/app/.cxx
key: android-build-${{ runner.os }}-${{ hashFiles('package.json', '**/*.gradle*', 'android/gradle.properties', 'android/settings.gradle') }}
restore-keys: |
android-build-${{ runner.os }}-
- name: Set gradle.properties
working-directory: android
run: |
printf '\n' >> ./gradle.properties
echo -e "reactNativeArchitectures=arm64-v8a,x86_64" >> ./gradle.properties
echo -e "VERSIONCODE=999999" >> ./gradle.properties
echo -e "KEYSTORE=release.keystore" >> ./gradle.properties
echo -e 'KEYSTORE_PASSWORD=${{ secrets.KEYSTORE_OFFICIAL_PASSWORD }}' >> ./gradle.properties
echo -e 'KEY_ALIAS=${{ secrets.KEYSTORE_OFFICIAL_ALIAS }}' >> ./gradle.properties
echo -e 'KEY_PASSWORD=${{ secrets.KEYSTORE_OFFICIAL_PASSWORD }}' >> ./gradle.properties
echo -e 'BugsnagAPIKey=${{ secrets.BUGSNAG_KEY_OFFICIAL }}' >> ./gradle.properties
- name: Build Android Release APK
if: ${{ steps.swap.outputs.swapped != 'true' }}
working-directory: android
run: ./gradlew assembleRelease --build-cache --parallel --max-workers=4 --no-daemon --stacktrace
env:
RUNNING_E2E_TESTS: true
- name: Prepare native build for cache
if: ${{ steps.native-cache.outputs.cache-hit != 'true' }}
run: |
mkdir -p .native-cache
cp "$APK_PATH" .native-cache/app-release.apk
.github/scripts/hash-dir.sh "$REACT_RES_DIR" > .native-cache/react-res.sha256
- name: Save native build to cache
if: ${{ steps.native-cache.outputs.cache-hit != 'true' }}
uses: actions/cache/save@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
with:
path: .native-cache
key: ${{ needs.native-fingerprint.outputs.cache-key }}
- name: Upload APK
if: ${{ !inputs.seed-only }}
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: Android APK
path: ${{ env.APK_PATH }}