Skip to content

Commit

Permalink
Allow using a published Liquid SDK plugin on Build CI's (#68)
Browse files Browse the repository at this point in the history
* Change provisioning profile for release mode

* Remove notification service app extension provisioning profiles from workflow

* Allow using a published Liquid SDK plugin on Build CI's

* Allow user to set a different Liquid SDK plugin version than latest published. If not set it'll target latest available on published git repository

* Rename and use "pubspec_overrides.yaml" to override dependency_overrides of pubspec.yaml that targets local repository for Liquid SDK plugins.

* Rename liquid_sdk_ref input to liquid-sdk-ref

* Set "use-published-plugins" to 'false' by default

* Apply workaround for testing workflow changes not pushed to main yet
  • Loading branch information
erdemyerebasmaz authored Jul 19, 2024
1 parent 0dc9fcf commit a559f3a
Show file tree
Hide file tree
Showing 9 changed files with 169 additions and 38 deletions.
78 changes: 70 additions & 8 deletions .github/workflows/build-android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,57 @@ name: Build Android
on:
workflow_dispatch:
inputs:
liquid_sdk_ref:
description: 'Liquid SDK commit/tag/branch reference'
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"

build-android:
needs: setup
name: Build Android
runs-on: macOS-latest
steps:
Expand All @@ -18,6 +61,14 @@ jobs:
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: 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 }}
Expand All @@ -31,6 +82,7 @@ jobs:
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
Expand All @@ -48,9 +100,11 @@ jobs:
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
Expand All @@ -65,60 +119,68 @@ jobs:
- name: 🏗️ Copy Firebase configuration file
working-directory: lbreez
env:
GOOGLE_SERVICES: ${{secrets.GOOGLE_SERVICES}}
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}}
ssh-key: ${{ secrets.REPO_SSH_KEY }}
path: 'breez-sdk-liquid'
ref: ${{ inputs.liquid_sdk_ref }}
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
just init-sdk
- 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: Generate Dart/Flutter bindings
if: ${{ needs.setup.outputs.use-published-plugins == 'false' }}
working-directory: breez-sdk-liquid/lib/bindings/langs/flutter/
continue-on-error: true
run: just codegen

- name: Generate FFI bindings
if: ${{ needs.setup.outputs.use-published-plugins == 'false' }}
working-directory: breez-sdk-liquid/lib/bindings/langs/flutter/
continue-on-error: true
run: just ffigen

- name: 🔒 Install SSH Key
env:
SSH_PRIVATE_KEY: ${{secrets.REPO_SSH_KEY}}
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
if: ${{ needs.setup.outputs.use-published-plugins == 'false' }}
working-directory: breez-sdk-liquid/lib/bindings/langs/flutter/
run: |
rm -rf ../../../target
just build
- name: 🔨 Build Android binaries
if: ${{ needs.setup.outputs.use-published-plugins == 'false' }}
working-directory: breez-sdk-liquid/lib/bindings/langs/flutter/
run: |
just build-android
Expand All @@ -138,11 +200,11 @@ jobs:

- name: ⚙️ Setup compile-time variables
env:
CONFIG_FILE: ${{secrets.CONFIG_FILE}}
CONFIG_FILE: ${{ secrets.CONFIG_FILE }}
run: echo "$CONFIG_FILE" > ./lbreez/config.json

- name: 🚀 Build Release apk
env:
env:
STORE_PASSWORD: ${{ secrets.STORE_PASSWORD }}
KEY_ALIAS: ${{ secrets.KEY_ALIAS }}
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
Expand Down
74 changes: 66 additions & 8 deletions .github/workflows/build-ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,56 @@ name: Build iOS
on:
workflow_dispatch:
inputs:
liquid_sdk_ref:
description: 'Liquid SDK commit/tag/branch reference'
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"

build-ios:
needs: setup
name: Build iOS
runs-on: macOS-latest
env:
Expand All @@ -27,7 +69,17 @@ jobs:
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: v${{ needs.setup.outputs.liquid-sdk-plugin-version }}/' pubspec_overrides.yaml
rm pubspec_overrides.yaml.bak
- name: Install rust
if: ${{ needs.setup.outputs.use-published-plugins == 'false' }}
run: |
rustup set auto-self-update disable
rustup toolchain install stable --profile minimal
Expand All @@ -45,9 +97,11 @@ jobs:
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
Expand Down Expand Up @@ -75,35 +129,41 @@ jobs:
run: echo "$GOOGLE_SERVICES_IOS" > ios/Runner/GoogleService-Info.plist

- 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: ${{ inputs.liquid_sdk_ref }}
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: Generate Dart/Flutter bindings
if: ${{ needs.setup.outputs.use-published-plugins == 'false' }}
working-directory: breez-sdk-liquid/lib/bindings/langs/flutter/
continue-on-error: true
run: just codegen

- name: Generate FFI bindings
if: ${{ needs.setup.outputs.use-published-plugins == 'false' }}
working-directory: breez-sdk-liquid/lib/bindings/langs/flutter/
continue-on-error: true
run: just ffigen
Expand All @@ -118,12 +178,14 @@ jobs:
ssh-add ~/.ssh/id_rsa
- name: 🔨 Build Breez Liquid SDK
if: ${{ needs.setup.outputs.use-published-plugins == 'false' }}
working-directory: breez-sdk-liquid/lib/bindings/langs/flutter/
run: |
rm -rf ../../../target
just build
- name: 🔨 Build iOS binaries
if: ${{ needs.setup.outputs.use-published-plugins == 'false' }}
working-directory: breez-sdk-liquid/lib/bindings/langs/flutter/
run: |
just build-apple
Expand All @@ -149,18 +211,14 @@ jobs:
- name: 📝 Install the Provisioning Profile
env:
PROVISIONING_PROFILE_BASE64: ${{ secrets.PROVISIONING_PROFILE_BASE64 }}
NOTIFICATION_PROVISIONING_PROFILE_BASE64: ${{ secrets.NOTIFICATION_PROVISIONING_PROFILE_BASE64 }}
run: |
# create variables
PP_PATH=$RUNNER_TEMP/build_pp.mobileprovision
NOTIFICATIONS_PP_PATH=$RUNNER_TEMP/build_notifications_pp.mobileprovision
# import provisioning profile from secrets
echo -n "$PROVISIONING_PROFILE_BASE64" | base64 --decode -o $PP_PATH
echo -n "$NOTIFICATION_PROVISIONING_PROFILE_BASE64" | base64 --decode -o $NOTIFICATIONS_PP_PATH
# apply provisioning profile
mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles
cp $PP_PATH ~/Library/MobileDevice/Provisioning\ Profiles
cp $NOTIFICATIONS_PP_PATH ~/Library/MobileDevice/Provisioning\ Profiles
- name: 🚀 Build app
working-directory: lbreez
Expand Down Expand Up @@ -210,4 +268,4 @@ jobs:
run: |
altool="$(dirname "$(xcode-select -p)")/Developer/usr/bin/altool"
ipa="$PWD/lbreez/build-output/ios/l_breez.ipa"
"$altool" --upload-app --type ios --file "$ipa" --username $TESTFLIGHT_USERNAME --password $TESTFLIGHT_PASSWORD
"$altool" --upload-app --type ios --file "$ipa" --username $TESTFLIGHT_USERNAME --password $TESTFLIGHT_PASSWORD
5 changes: 2 additions & 3 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ PODS:
- GoogleUtilities/UserDefaults (~> 7.8)
- nanopb (< 2.30911.0, >= 2.30908.0)
- Flutter (1.0.0)
- flutter_breez_liquid (0.1.0):
- Flutter
- flutter_breez_liquid (0.1.0)
- flutter_fgbg (0.0.1):
- Flutter
- flutter_inappwebview_ios (0.0.1):
Expand Down Expand Up @@ -295,7 +294,7 @@ SPEC CHECKSUMS:
FirebaseInstallations: 913cf60d0400ebd5d6b63a28b290372ab44590dd
FirebaseMessaging: 087a7c7cadef7b9239f005bc4db823894844f323
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
flutter_breez_liquid: 707cf69d42f3efbe37836a6fc0d1e7ea7d400e4b
flutter_breez_liquid: b61267976647a385b0446e628fe69421153513f7
flutter_fgbg: 31c0d1140a131daea2d342121808f6aa0dcd879d
flutter_inappwebview_ios: 97215cf7d4677db55df76782dbd2930c5e1c1ea0
flutter_keyboard_visibility: 0339d06371254c3eb25eeb90ba8d17dca8f9c069
Expand Down
7 changes: 5 additions & 2 deletions ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -758,9 +758,11 @@
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = F7R2LZH3W5;
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = F7R2LZH3W5;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
Expand All @@ -770,6 +772,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.breez.liquid.lBreez;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
"PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" = "mistybreez-dist-profile";
STRIP_STYLE = "non-global";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
SWIFT_VERSION = 5.0;
Expand Down
Loading

0 comments on commit a559f3a

Please sign in to comment.