Build Android #44
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 (MAJOR.MINOR.BUILD). Default = "main"' | |
required: false | |
type: string | |
default: 'main' | |
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: | |
- run: echo "set pre-setup output variables" | |
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" | |
- name: 🏗️ Setup l-breez repository | |
uses: actions/checkout@v4 | |
with: | |
path: 'lbreez' | |
- name: 🏗️ Setup Flutter | |
uses: subosito/flutter-action@v2 | |
with: | |
channel: 'stable' | |
cache: true | |
build-sdk: | |
needs: setup | |
name: Build Liquid SDK | |
runs-on: macOS-latest | |
if: ${{ needs.setup.outputs.use-published-plugins == 'false' }} | |
steps: | |
- name: Install rust | |
run: | | |
rustup set auto-self-update disable | |
rustup toolchain install stable --profile minimal | |
- name: Set up just | |
uses: extractions/setup-just@v2 | |
- name: Set up Melos | |
uses: bluefireteam/melos-action@v3 | |
with: | |
run-bootstrap: false | |
- name: 🏗️ Setup breez-sdk-liquid repository | |
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 | |
uses: Swatinem/rust-cache@v2 | |
with: | |
workspaces: breez-sdk-liquid/lib/ | |
cache-all-crates: true | |
- name: 📦 Install Breez Liquid SDK dependencies | |
working-directory: breez-sdk-liquid/lib/bindings/langs/flutter/ | |
run: | | |
just clean | |
just init | |
just init-sdk | |
- name: Install flutter_rust_bridge_codegen dependencies | |
working-directory: breez-sdk-liquid/lib/bindings/langs/flutter/ | |
run: just frb | |
- name: Generate Dart/Flutter bindings | |
working-directory: breez-sdk-liquid/lib/bindings/langs/flutter/ | |
continue-on-error: true | |
run: just codegen | |
- name: Generate FFI bindings | |
working-directory: breez-sdk-liquid/lib/bindings/langs/flutter/ | |
continue-on-error: true | |
run: just ffigen | |
- name: 🔨 Build Breez Liquid SDK | |
working-directory: breez-sdk-liquid/lib/bindings/langs/flutter/ | |
run: | | |
rm -rf ../../../target | |
just build | |
- name: 🔨 Build Android binaries | |
working-directory: breez-sdk-liquid/lib/bindings/langs/flutter/ | |
run: | | |
just build-android | |
just link | |
configurations: | |
needs: [setup, build-sdk] | |
name: Setup Configurations | |
runs-on: macOS-latest | |
steps: | |
- 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: v${{ 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: 🏗️ Android cache | |
id: android-cache | |
uses: actions/cache@v3 | |
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: 🔒 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: ⚙️ Setup compile-time variables | |
env: | |
CONFIG_FILE: ${{ secrets.CONFIG_FILE }} | |
run: echo "$CONFIG_FILE" > ./lbreez/config.json | |
build-android: | |
needs: [setup, build-sdk, configurations] | |
name: Build Android | |
runs-on: macOS-latest | |
steps: | |
- 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: 🚀 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@v3 | |
with: | |
name: Android-APK | |
path: lbreez/build/app/outputs/flutter-apk/app-*.apk |