-
Notifications
You must be signed in to change notification settings - Fork 2
304 lines (266 loc) · 11.8 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
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
name: Build Android
on:
workflow_dispatch:
inputs:
use-published-plugins:
description: 'Boolean indicating whether to use a published plugin for the SDK. Default = false.'
required: false
type: boolean
default: false
liquid-sdk-plugin-version:
description: 'Version for the published Liquid SDK plugin "v(MAJOR.MINOR.BUILD)". Defaults to latest published version on "breez/breez-sdk-liquid-flutter"'
required: false
type: string
default: ''
liquid-sdk-ref:
description: 'Liquid SDK commit/tag/branch reference when not using a published plugin. Default = "main"'
required: false
type: string
default: 'main'
jobs:
pre-setup:
name: Pre-setup
runs-on: ubuntu-latest
outputs:
# These outputs mimic the inputs for the workflow.
# Their only purpose is to be able to test this workflow if you make
# changes that you won't want to commit to main yet.
# You can set these values manually, to test how the CI behaves with
# certain inputs.
use-published-plugins: ${{ inputs.use-published-plugins }}
liquid-sdk-plugin-version: ${{ inputs.liquid-sdk-plugin-version }}
liquid-sdk-ref: ${{ inputs.liquid-sdk-ref }}
steps:
- name: Checkout repository
if: ${{ needs.pre-setup.outputs.use-published-plugins == 'true' && needs.pre-setup.outputs.liquid-sdk-plugin-version == ''}}
uses: actions/checkout@v4
with:
repository: 'breez/breez-sdk-liquid-flutter'
- name: Get the latest tag and set 'liquid-sdk-plugin-version'
if: ${{ needs.pre-setup.outputs.use-published-plugins == 'true' && needs.pre-setup.outputs.liquid-sdk-plugin-version == ''}}
run: |
latest_tag=$(git describe --tags `git rev-list --tags --max-count=1`)
echo "::set-output name=liquid-sdk-plugin-version::$latest_tag"
- run: echo "set pre-setup output variables"
- name: Disk Cleanup
run: |
echo "::group::Free space before cleanup"
df -h --total
echo "::endgroup::"
echo "::group::Cleaned Files"
sudo rm -rf /usr/local/.ghcup
sudo rm -rf /opt/hostedtoolcache/CodeQL
sudo rm -rf /usr/local/lib/android/sdk/ndk
sudo rm -rf /usr/share/dotnet
sudo rm -rf /opt/ghc
sudo rm -rf /usr/local/share/boost
sudo apt-get clean
echo "::endgroup::"
echo "::group::Free space after cleanup"
df -h --total
echo "::endgroup::"
setup:
name: Setup
needs: pre-setup
runs-on: ubuntu-latest
outputs:
# Careful, a boolean input is not a boolean output. A boolean input is
# actually a boolean, but these outputs are strings. All the boolean
# checks in this file have the format `boolean == 'true'`. So feel free
# to set these variables here to `true` or `false`
# (e.g. bindings-windows: true) if you want to test something.
use-published-plugins: ${{ needs.pre-setup.outputs.use-published-plugins }}
liquid-sdk-plugin-version: ${{ needs.pre-setup.outputs.liquid-sdk-plugin-version }}
liquid-sdk-ref: ${{ needs.pre-setup.outputs.liquid-sdk-ref }}
steps:
- run: echo "set setup output variables"
build-android:
needs: setup
name: Build Android
runs-on: macOS-latest
env:
FIREBASE_PROJECT: breez-technology
FIREBASE_ANDROID_PACKAGE_NAME: com.breez.liquid.l_breez
FIREBASE_IOS_BUNDLE_ID: com.breez.liquid.lBreez
# A bug causes 'flutterfire configure' to require app id's for non-selected platforms on CI workflows https://github.com/invertase/flutterfire_cli/issues/233
# If the app id does not exists on project, 'flutterfire configure' automatically create an app with that app id, that is why an existing app id is used here.
FIREBASE_PLACEHOLDER_APP_ID: com.breez.liquid.lBreez
GOOGLE_APPLICATION_CREDENTIALS_BASE64: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS_BASE64 }}
steps:
- name: Disk Cleanup
run: |
echo "::group::Free space before cleanup"
df -hI
echo "::endgroup::"
echo "::group::Cleaned Files"
sudo rm -rf /Applications/Xcode_14.3.1.app
sudo rm -rf /Applications/Xcode_15.0.1.app
sudo rm -rf /Applications/Xcode_15.1.app
sudo rm -rf /Applications/Xcode_15.2.app
sudo rm -rf /Applications/Xcode_15.3.app
echo "::endgroup::"
echo "::group::Free space after cleanup"
df -hI
echo "::endgroup::"
- name: 🏗️ Check-out l-breez repository
uses: actions/checkout@v4
with:
path: 'lbreez'
- name: Set Liquid SDK plugin version
if: ${{ needs.setup.outputs.use-published-plugins == 'true' }}
working-directory: lbreez
run: |
mv pubspec_overrides.yaml.workflow pubspec_overrides.yaml
sed -i.bak -e 's/ref:.*/ref: ${{ needs.setup.outputs.liquid-sdk-plugin-version }}/' pubspec_overrides.yaml
rm pubspec_overrides.yaml.bak
- name: Decode Keystore
env:
STORE_FILE_BASE64: ${{ secrets.STORE_FILE_BASE64 }}
STORE_FILE: ${RUNNER_TEMP}/keystore/lbreez-release.keystore
run: |
echo "STORE_FILE=${RUNNER_TEMP}/keystore/lbreez-release.keystore" >> $GITHUB_ENV
echo "STORE_FILE=${RUNNER_TEMP}/keystore/lbreez-release.keystore"
TMP_KEYSTORE_FILE_PATH=${RUNNER_TEMP}/keystore
mkdir -p ${TMP_KEYSTORE_FILE_PATH}
echo $STORE_FILE_BASE64 | base64 -do ${TMP_KEYSTORE_FILE_PATH}/lbreez-release.keystore
echo "${TMP_KEYSTORE_FILE_PATH}/lbreez-release.keystore"
- name: Install rust
if: ${{ needs.setup.outputs.use-published-plugins == 'false' }}
run: |
rustup set auto-self-update disable
rustup toolchain install stable --profile minimal
- name: Install Protoc
if: ${{ needs.setup.outputs.use-published-plugins == 'false' }}
uses: arduino/setup-protoc@v3
with:
version: "27.2"
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: 🏗️ Setup Java
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: '17'
- name: 🏗️ Setup Flutter
uses: subosito/flutter-action@v2
with:
channel: 'stable'
flutter-version: 3.22.3 # Pinned until resource linking issues on Android is resolved with 3.24
cache: true
- name: Set up just
if: ${{ needs.setup.outputs.use-published-plugins == 'false' }}
uses: extractions/setup-just@v2
- name: Set up Melos
if: ${{ needs.setup.outputs.use-published-plugins == 'false' }}
uses: bluefireteam/melos-action@v3
with:
run-bootstrap: false
- name: Set up Firebase CLI
run: sudo npm i -g firebase-tools
- name: Decode Google Application Credentials
working-directory: lbreez
run: base64 --decode <<< $GOOGLE_APPLICATION_CREDENTIALS_BASE64 > google-application-credentials.json
- name: Set up FlutterFire
working-directory: lbreez
run: dart pub global activate flutterfire_cli
- name: Configure Firebase
working-directory: lbreez
run: flutterfire configure -p $FIREBASE_PROJECT -o lib/firebase/firebase_options.dart --platforms="android,ios" -a $FIREBASE_ANDROID_PACKAGE_NAME -i $FIREBASE_IOS_BUNDLE_ID -m $FIREBASE_PLACEHOLDER_APP_ID -w $FIREBASE_PLACEHOLDER_APP_ID -x $FIREBASE_PLACEHOLDER_APP_ID --service-account=google-application-credentials.json -y
- name: 🏗️ Android cache
id: android-cache
uses: actions/cache@v4
with:
path: ~/.android/debug.keystore
key: debug.keystore
- name: 🏗️ Copy Firebase configuration file
working-directory: lbreez
env:
GOOGLE_SERVICES: ${{ secrets.GOOGLE_SERVICES }}
run: echo "$GOOGLE_SERVICES" > android/app/google-services.json
- name: 🏗️ Setup breez-sdk-liquid repository
if: ${{ needs.setup.outputs.use-published-plugins == 'false' }}
uses: actions/checkout@v4
with:
repository: 'breez/breez-sdk-liquid'
ssh-key: ${{ secrets.REPO_SSH_KEY }}
path: 'breez-sdk-liquid'
ref: ${{ needs.setup.outputs.liquid-sdk-ref }}
- name: 🏗️ Rust cache
if: ${{ needs.setup.outputs.use-published-plugins == 'false' }}
uses: Swatinem/rust-cache@v2
with:
workspaces: breez-sdk-liquid/lib/
cache-all-crates: true
- name: 📦 Install Breez Liquid SDK dependencies
if: ${{ needs.setup.outputs.use-published-plugins == 'false' }}
working-directory: breez-sdk-liquid/lib/bindings/langs/flutter/
run: |
just clean
just init
- name: Install flutter_rust_bridge_codegen dependencies
if: ${{ needs.setup.outputs.use-published-plugins == 'false' }}
working-directory: breez-sdk-liquid/lib/bindings/langs/flutter/
run: just frb
- name: 🔒 Install SSH Key
env:
SSH_PRIVATE_KEY: ${{ secrets.REPO_SSH_KEY }}
run: |
mkdir -p ~/.ssh
echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa
sudo chmod 600 ~/.ssh/id_rsa
ssh-add ~/.ssh/id_rsa
- name: 🔨 Build Breez Liquid SDK Android bindings
if: ${{ needs.setup.outputs.use-published-plugins == 'false' }}
working-directory: breez-sdk-liquid/lib/bindings/langs/flutter/
run: just build-uniffi-android
- name: Generate Dart/Flutter bindings & Softlink C Headers
if: ${{ needs.setup.outputs.use-published-plugins == 'false' }}
working-directory: breez-sdk-liquid/lib/bindings/langs/flutter/
continue-on-error: true
run: just gen false
- name: 🗂️ Populate Flutter tool's cache of binary artifacts.
working-directory: lbreez
run: flutter precache
- name: 📦 Install Flutter dependencies
working-directory: lbreez
run: flutter pub get
- name: 🔍 Perform static analysis
working-directory: lbreez
run: dart analyze --fatal-infos
- name: ⚙️ Setup compile-time variables
env:
CONFIG_FILE: ${{ secrets.CONFIG_FILE }}
run: echo "$CONFIG_FILE" > ./lbreez/config.json
- name: 🚀 Build Release apk
env:
STORE_PASSWORD: ${{ secrets.STORE_PASSWORD }}
KEY_ALIAS: ${{ secrets.KEY_ALIAS }}
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
working-directory: lbreez
run: flutter build apk --target=lib/main/main.dart --release --split-debug-info=./obsfucated/debug --obfuscate --no-pub --split-per-abi --dart-define-from-file=config.json
- name: 🗃️ Compress build folder (APK)
if: github.event_name == 'release'
uses: TheDoctor0/zip-release@master
with:
filename: build.zip
directory: lbreez/build/app/outputs/flutter-apk
type: zip
- name: 📤 Upload asset (APK)
if: github.event_name == 'release'
uses: svenstaro/upload-release-action@v2
with:
asset_name: Android-APK.zip
file: lbreez/build/app/outputs/flutter-apk/build.zip
overwrite: true
repo_token: ${{ secrets.GITHUB_TOKEN }}
- name: 📤 Upload artifact (APK)
if: github.event_name != 'release'
uses: actions/upload-artifact@v4
with:
name: Android-APK
path: lbreez/build/app/outputs/flutter-apk/app-*.apk
- name: Cleanup Google Application Credentials
if: success() || failure()
run: |
if [ -d "lbreez" ] && [ -f "lbreez/google-application-credentials.json" ]; then
rm lbreez/google-application-credentials.json
fi