Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CI workflows #11

Merged
merged 4 commits into from
Jun 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Run CI
on:
# Triggers the workflow on push events but only for the "main" branch
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
workflow_dispatch:
inputs:
liquid_sdk_ref:
description: 'Liquid SDK commit/tag/branch reference'
required: false
type: string
default: 'main'
breez_sdk_ref:
description: 'Breez SDK commit/tag/branch reference'
required: false
type: string
default: 'flutter_rust_bridge_v2'
jobs:
build:
runs-on: macOS-latest
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- name: 🏗️ Setup l-breez repository
uses: actions/checkout@v4
with:
path: 'lbreez'

# TODO: Liquid - Revert once breez-sdk dependency is removed
- 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.breez_sdk_ref }}

- name: 🏗️ Setup breez-liquid-sdk repository
uses: actions/checkout@v4
with:
repository: 'breez/breez-liquid-sdk'
ssh-key: ${{secrets.REPO_SSH_KEY}}
path: 'breez-liquid-sdk'
ref: ${{ inputs.liquid_sdk_ref }}

- 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: 📦 Install Flutter dependencies
working-directory: lbreez
run: flutter pub get

- name: 🔍 Perform static analysis
working-directory: lbreez
run: dart analyze --fatal-infos

- name: Check Formatting
working-directory: lbreez
run: dart format -o none --set-exit-if-changed -l 110 .
191 changes: 191 additions & 0 deletions .github/workflows/build-android.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
name: Build Android
on:
workflow_dispatch:
inputs:
liquid_sdk_ref:
description: 'Liquid SDK commit/tag/branch reference'
required: false
type: string
default: 'main'
breez_sdk_ref:
description: 'Breez SDK commit/tag/branch reference'
required: false
type: string
default: 'flutter_rust_bridge_v2'

jobs:
build-android:
name: Build Android
runs-on: macOS-latest
steps:
- name: 🏗️ Setup l-breez repository
uses: actions/checkout@v4
with:
path: 'lbreez'

- 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
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: Set up just
uses: extractions/setup-just@v2

- name: Set up Melos
uses: bluefireteam/melos-action@v3
with:
run-bootstrap: false

- 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

# TODO: Liquid - Revert once breez-sdk dependency is removed
- 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.breez_sdk_ref }}

- name: 🏗️ Setup breez-liquid-sdk repository
uses: actions/checkout@v4
with:
repository: 'breez/breez-liquid-sdk'
ssh-key: ${{secrets.REPO_SSH_KEY}}
path: 'breez-liquid-sdk'
ref: ${{ inputs.liquid_sdk_ref }}

- name: 🏗️ Rust cache
uses: Swatinem/rust-cache@v2
with:
workspaces: breez-liquid-sdk/lib/
cache-all-crates: true

- name: 📦 Install Breez Liquid SDK dependencies
working-directory: breez-liquid-sdk/lib/bindings/langs/flutter/
run: |
just clean
just init

- name: Install flutter_rust_bridge_codegen dependencies
working-directory: breez-liquid-sdk/lib/bindings/langs/flutter/
run: just frb

- name: Generate Dart/Flutter bindings
working-directory: breez-liquid-sdk/lib/bindings/langs/flutter/
continue-on-error: true
run: just codegen

- name: Generate FFI bindings
working-directory: breez-liquid-sdk/lib/bindings/langs/flutter/
continue-on-error: true
run: just ffigen

- 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
working-directory: breez-liquid-sdk/lib/bindings/langs/flutter/
run: |
rm -rf ../../../target
just build

- name: 🔨 Build Android binaries
working-directory: breez-liquid-sdk/lib/bindings/langs/flutter/
run: |
just build-android
just link

- 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: 🛠️ Run tests
working-directory: lbreez
run: flutter test

- 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 --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
Loading
Loading