Skip to content

Build Android

Build Android #199

Workflow file for this run

name: Build Android
on:
workflow_dispatch:
inputs:
ref:
description: 'SDK commit/tag/branch reference'
required: false
type: string
default: 'main'
jobs:
build-android:
name: Build Android
runs-on: macOS-latest
steps:
- name: πŸ—οΈ Setup c-breez repository
uses: actions/checkout@v4
with:
path: 'cbreez'
- name: Decode Keystore
env:
STORE_FILE_BASE64: ${{ secrets.STORE_FILE_BASE64 }}
STORE_FILE: ${RUNNER_TEMP}/keystore/cbreez-release.keystore
run: |
echo "STORE_FILE=${RUNNER_TEMP}/keystore/cbreez-release.keystore" >> $GITHUB_ENV
echo "STORE_FILE=${RUNNER_TEMP}/keystore/cbreez-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}/cbreez-release.keystore
echo "${TMP_KEYSTORE_FILE_PATH}/cbreez-release.keystore"
- name: Install rust
run: |
rustup set auto-self-update disable
rustup toolchain install stable --profile minimal
- 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'
cache: true
- 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: cbreez
env:
GOOGLE_SERVICES: ${{secrets.GOOGLE_SERVICES}}
run: echo "$GOOGLE_SERVICES" > android/app/google-services.json
- name: πŸ—οΈ Setup breez-sdk repository
uses: actions/checkout@v4
with:
repository: 'breez/breez-sdk'
ssh-key: ${{secrets.REPO_SSH_KEY}}
path: 'breez-sdk'
ref: ${{ inputs.ref }}
- name: πŸ—οΈ Rust cache
uses: Swatinem/rust-cache@v2
with:
workspaces: breez-sdk/libs
cache-all-crates: true
- name: πŸ“¦ Install Breez SDK dependencies
run: |
cargo install cargo-ndk
brew install protobuf
cd breez-sdk/libs/sdk-flutter
make init
cd ../sdk-core
make init
- 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 SDK
working-directory: breez-sdk/libs/sdk-flutter
run: |
rm -rf ../target
cargo check
make android
- name: πŸ—‚οΈ Populate Flutter tool's cache of binary artifacts.
working-directory: cbreez
run: flutter precache
- name: πŸ“¦ Install Flutter dependencies
working-directory: cbreez
run: flutter pub get
- name: πŸ” Perform static analysis
working-directory: cbreez
run: dart analyze --fatal-infos
- name: πŸ› οΈ Run tests
working-directory: cbreez
run: flutter test
- name: βš™οΈ Setup compile-time variables
env:
CONFIG_FILE: ${{secrets.CONFIG_FILE}}
run: echo "$CONFIG_FILE" > ./cbreez/config.json
- name: πŸš€ Build Release apk
env:
STORE_PASSWORD: ${{ secrets.STORE_PASSWORD }}
KEY_ALIAS: ${{ secrets.KEY_ALIAS }}
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
working-directory: cbreez
run: flutter build apk --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: cbreez/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: cbreez/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: cbreez/build/app/outputs/flutter-apk/app-*.apk