-
Notifications
You must be signed in to change notification settings - Fork 0
175 lines (172 loc) · 6.75 KB
/
client-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
name: Android Client
on:
workflow_dispatch:
inputs:
releaseAPK:
description: 'type "release-apk" to confirm upload to S3'
required: false
releaseGooglePlay:
description: 'type "release-google-play" to confirm release to Google Play'
required: false
schedule:
- cron: '20 5 * * 1,3,5' # 5:20 AM UTC time on every Monday, Wednesday and Friday
pull_request:
paths:
- .github/workflows/client-android.yml
- secrets/**
- android/**
- fastlane/**
- Gemfile.lock
- .ruby-version
- yarn.lock
push:
branches: [master, sdk-*]
paths:
- .github/workflows/client-android.yml
- secrets/**
- android/**
- fastlane/**
- Gemfile.lock
- .ruby-version
- yarn.lock
concurrency:
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-18.04
steps:
- name: 👀 Checkout
uses: actions/checkout@v2
with:
submodules: true
- name: ♻️ Restore workspace node modules
uses: actions/cache@v2
id: node-modules-cache
with:
path: |
# See "workspaces" → "packages" in the root package.json for the source of truth of
# which node_modules are affected by the root yarn.lock
node_modules
apps/*/node_modules
home/node_modules
packages/*/node_modules
packages/@unimodules/*/node_modules
react-native-lab/react-native/node_modules
key: ${{ runner.os }}-modules-${{ hashFiles('yarn.lock') }}
- run: echo "$(pwd)/bin" >> $GITHUB_PATH
- name: ♻️ Restore node modules in tools
uses: actions/cache@v2
with:
path: tools/node_modules
key: ${{ runner.os }}-tools-modules-${{ hashFiles('tools/yarn.lock') }}
- name: 🧶 Yarn install
run: yarn install --frozen-lockfile
- name: 💎 Setup Ruby and install gems
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
- name: 🐙 Install git-crypt
run: sudo apt-get install git-crypt
- name: 🔓 Decrypt secrets if possible
env:
GIT_CRYPT_KEY_BASE64: ${{ secrets.GIT_CRYPT_KEY_BASE64 }}
run: |
if [ -z "${GIT_CRYPT_KEY_BASE64}" ]; then
echo 'git-crypt key not present in environment'
else
git crypt unlock <(echo $GIT_CRYPT_KEY_BASE64 | base64 --decode)
fi
- name: ♻️ Restore Gradle caches
uses: actions/cache@v2
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('android/*.gradle*') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: ♻️ Restore Android NDK from cache
uses: actions/cache@v2
id: cache-android-ndk
with:
path: /usr/local/lib/android/sdk/ndk/19.2.5345600/
key: ${{ runner.os }}-ndk-19.2.5345600
restore-keys: |
${{ runner.os }}-ndk-
- name: 🛠 Install NDK
if: steps.cache-android-ndk.outputs.cache-hit != 'true'
run: |
sudo $ANDROID_SDK_ROOT/tools/bin/sdkmanager --install "ndk;19.2.5345600"
- name: 🔎 Check which flavor to build
id: flavor
uses: dorny/paths-filter@v2
with:
# this action fails when base is not set on schedule event
base: ${{ github.ref }}
filters: |
versioned:
- android/versioned-abis/**
- android/versioned-react-native/**
- android/expoview/src/versioned/**
- android/expoview/src/main/java/versioned/**
- android/**/*.gradle
- name: 🏭 Build APK
env:
ANDROID_KEYSTORE_B64: ${{ secrets.ANDROID_KEYSTORE_B64 }}
ANDROID_KEYSTORE_PASSWORD: ${{ secrets.ANDROID_KEYSTORE_PASSWORD }}
ANDROID_KEY_ALIAS: ExponentKey
ANDROID_KEY_PASSWORD: ${{ secrets.ANDROID_KEY_PASSWORD }}
ANDROID_NDK_HOME: /usr/local/lib/android/sdk/ndk/19.2.5345600/
IS_RELEASE_BUILD: ${{ github.event.inputs.releaseAPK == 'release-apk' || github.event.inputs.releaseGooglePlay == 'release-google-play' }}
IS_VERSIONED_FLAVOR: ${{ github.event_name == 'schedule' || steps.flavor.outputs.versioned == 'true' }}
run: |
if [ "$IS_RELEASE_BUILD" == "false" ]; then
export NDK_ABI_FILTERS="x86_64"
BUILD_TYPE="Debug"
echo "Using ABI filters: $NDK_ABI_FILTERS"
else
BUILD_TYPE="Release"
fi
[[ "$IS_VERSIONED_FLAVOR" == "true" ]] && FLAVOR="Versioned" || FLAVOR="Unversioned"
echo "Building with $FLAVOR flavor"
if [ -z "$ANDROID_KEYSTORE_B64" ]; then
echo "External build detected, APK will not be signed"
bin/fastlane android build build_type:$BUILD_TYPE flavor:$FLAVOR sign:false
else
echo "Internal build detected, APK will be signed"
echo $ANDROID_KEYSTORE_B64 | base64 -d > android/app/release-key.jks
bin/fastlane android build build_type:$BUILD_TYPE flavor:$FLAVOR
fi
- name: 💾 Upload APK artifact
uses: actions/upload-artifact@v2
with:
name: android-apk
path: android/app/build/outputs/apk
- name: 💾 Store daemon logs for debugging crashes
if: failure()
uses: actions/upload-artifact@v2
with:
name: gradle-daemon-logs
path: ~/.gradle/daemon
- name: 📤 Upload APK to S3 and update staging versions endpoint
if: ${{ github.event.inputs.releaseAPK == 'release-apk' }}
run: bin/expotools client-build --platform android --release
env:
AWS_ACCESS_KEY_ID: AKIAJ3SWUQ4QLNQC7FXA
AWS_SECRET_ACCESS_KEY: ${{ secrets.android_client_build_aws_secret_key }}
EXPO_VERSIONS_SECRET: ${{ secrets.expo_versions_secret }}
- name: 📤 Upload APK to Google Play and release to production
if: ${{ github.event.inputs.releaseGooglePlay == 'release-google-play' }}
run: bin/fastlane android prod_release
env:
SUPPLY_JSON_KEY_DATA: ${{ secrets.SUPPLY_JSON_KEY_DATA }}
- name: 🔔 Notify on Slack
uses: 8398a7/action-slack@v3
if: failure() && (github.event.ref == 'refs/heads/master' || startsWith(github.event.ref, 'refs/heads/sdk-'))
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SLACK_WEBHOOK_URL: ${{ secrets.slack_webhook_android }}
with:
channel: '#platform-android'
status: ${{ job.status }}
fields: job,message,ref,eventName,author,took
author_name: Expo Go (Android)