Build iOS #18
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 iOS | |
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" | |
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-14 | |
env: | |
SCHEME: Runner | |
BUILD_CONFIGURATION: Release | |
TESTFLIGHT_USERNAME: ${{secrets.TESTFLIGHT_USERNAME}} | |
TESTFLIGHT_PASSWORD: ${{secrets.TESTFLIGHT_PASSWORD}} | |
IOS_VERSION_STRING: 0.1.0 | |
DISTRIBUTION_CERT: ${{secrets.DISTRIBUTION_CERT}} | |
P12_BASE64: ${{secrets.P12_BASE64}} | |
P12_PASSWORD: ${{secrets.P12_PASSWORD}} | |
GOOGLE_SERVICES_IOS: ${{secrets.GOOGLE_SERVICES_IOS}} | |
steps: | |
- name: 🏗️ Setup 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: 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' | |
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: 🔐 Install Keychain keys | |
run: | | |
KEYCHAIN_PATH=$RUNNER_TEMP/ios-build.keychain | |
security create-keychain -p ci $KEYCHAIN_PATH | |
security default-keychain -s $KEYCHAIN_PATH | |
security unlock-keychain -p ci $KEYCHAIN_PATH | |
security set-keychain-settings -t 6400 -l $KEYCHAIN_PATH | |
CERT_PATH=$RUNNER_TEMP/apple_distribution.cer | |
echo -n "$DISTRIBUTION_CERT" | base64 --decode -o $CERT_PATH | |
security import $CERT_PATH -k $KEYCHAIN_PATH -A | |
P12_KEY_PATH=$RUNNER_TEMP/key.p12 | |
echo -n "$P12_BASE64" | base64 --decode -o $P12_KEY_PATH | |
security import $P12_KEY_PATH -k $KEYCHAIN_PATH -P "$P12_PASSWORD" -A | |
security set-key-partition-list -S apple-tool:,apple: -s -k ci $KEYCHAIN_PATH > /dev/null | |
- name: 🏗️ Copy Firebase configuration file | |
working-directory: lbreez | |
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: ${{ 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 | |
- 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 | |
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 | |
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: ⚙️ Setup compile-time variables | |
env: | |
CONFIG_FILE: ${{secrets.CONFIG_FILE}} | |
run: echo "$CONFIG_FILE" > ./lbreez/config.json | |
- name: 📝 Install the Provisioning Profile | |
env: | |
PROVISIONING_PROFILE_BASE64: ${{ secrets.PROVISIONING_PROFILE_BASE64 }} | |
run: | | |
# create variables | |
PP_PATH=$RUNNER_TEMP/build_pp.mobileprovision | |
# import provisioning profile from secrets | |
echo -n "$PROVISIONING_PROFILE_BASE64" | base64 --decode -o $PP_PATH | |
# apply provisioning profile | |
mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles | |
cp $PP_PATH ~/Library/MobileDevice/Provisioning\ Profiles | |
- name: 🚀 Build app | |
working-directory: lbreez | |
run: flutter build ios --target=lib/main/main.dart --release --split-debug-info=./obsfucated/debug --obfuscate --config-only --no-pub --no-codesign --dart-define-from-file=config.json | |
- name: 📦 Resolve Swift package dependencies | |
working-directory: lbreez | |
run: xcodebuild -resolvePackageDependencies -workspace ios/Runner.xcworkspace -scheme ${{ env.SCHEME }} -configuration ${{ env.BUILD_CONFIGURATION }} | |
- name: 🔨 Build application and generate xcarchive file | |
working-directory: lbreez | |
run: | | |
buildNumber=$(($GITHUB_RUN_NUMBER + 6000)).1 | |
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber" ios/Runner/Info.plist | |
/usr/libexec/PlistBuddy -c "Set :CFBundleShortVersionString ${{ env.IOS_VERSION_STRING }}" ios/Runner/Info.plist | |
xcodebuild -workspace ios/Runner.xcworkspace -scheme ${{ env.SCHEME }} -configuration ${{ env.BUILD_CONFIGURATION }} -sdk 'iphoneos' -destination 'generic/platform=iOS' -archivePath build-output/app.xcarchive clean archive | |
- name: 📤 Export the archive to an ipa file | |
working-directory: lbreez | |
run: xcodebuild -exportArchive -archivePath build-output/app.xcarchive -exportPath build-output/ios -exportOptionsPlist ios/ExportOptions.plist | |
- name: 🗃️ Compress build folder | |
if: github.event_name == 'release' | |
uses: TheDoctor0/zip-release@master | |
with: | |
filename: build.zip | |
directory: lbreez/build/ios/iphoneos | |
type: zip | |
- name: 📤 Upload release | |
if: github.event_name == 'release' | |
uses: svenstaro/upload-release-action@v2 | |
with: | |
asset_name: release-iOS.zip | |
file: lbreez/build/ios/iphoneos/build.zip | |
overwrite: true | |
repo_token: ${{ secrets.GITHUB_TOKEN }} | |
- name: 📤 Upload artifact | |
if: github.event_name != 'release' | |
uses: actions/upload-artifact@v4 | |
with: | |
name: release-iOS | |
path: lbreez/build/ios/iphoneos | |
- name: 📱 Publish to TestFlight | |
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 |