Skip to content

Build iOS

Build iOS #93

Workflow file for this run

name: Build IOS
# Controls when the workflow will run
on:
# Triggers the workflow on push events but only for the "main" branch
# push:
# branches: [ "main" ]
# pull_request:
# branches: [ "main" ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
build:
runs-on: macOS-latest
env:
SHEME: 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:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3
with:
path: 'cbreez'
- 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 --output $CERT_PATH
security import $CERT_PATH -k $KEYCHAIN_PATH -A
P12_KEY_PATH=$RUNNER_TEMP/key.p12
echo -n "$P12_BASE64" | base64 --decode --output $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-config
run: |
cd cbreez
echo "$GOOGLE_SERVICES_IOS" > ios/Runner/GoogleService-Info.plist
- uses: actions/checkout@v3
with:
repository: 'breez/breez-sdk'
ssh-key: ${{secrets.REPO_SSH_KEY}}
path: 'breez-sdk'
# Setup the flutter environment.
- uses: subosito/flutter-action@v2
with:
flutter-version: '3.7.12'
channel: 'stable'
- name: install dependencies
run: |
cargo install [email protected]
brew install protobuf
cd breez-sdk/libs/sdk-flutter
make init
cd ../sdk-core
make init
- name: build sdk
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
cd breez-sdk/libs/sdk-flutter
make ios-dev
- uses: actions/setup-java@v2
with:
distribution: 'zulu'
java-version: '17'
- name: flutter-doctor
run: |
cd cbreez
flutter doctor
- name: pub-get
run: |
cd cbreez
flutter pub get
- name: dart-analyze
run: |
cd cbreez
dart analyze --fatal-infos
- name: run-tests
run: |
cd cbreez
flutter test
- 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 --output $PP_PATH
# apply provisioning profile
mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles
cp $PP_PATH ~/Library/MobileDevice/Provisioning\ Profiles
- name: override-config
env:
CONFIG_FILE: ${{secrets.CONFIG_FILE}}
run: |
echo "$CONFIG_FILE" > ./cbreez/config.json
- name: Build Flutter
run: |
cd cbreez
flutter build ios --release --no-codesign --dart-define-from-file=config.json
- name: Build resolve Swift dependencies
run: |
cd cbreez
xcodebuild -resolvePackageDependencies -workspace ios/Runner.xcworkspace -scheme ${{ env.SHEME }} -configuration ${{ env.BUILD_CONFIGURATION }}
- name: Build xArchive
run: |
cd cbreez
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.SHEME }} -configuration ${{ env.BUILD_CONFIGURATION }} -sdk 'iphoneos' -destination 'generic/platform=iOS' -archivePath build-output/app.xcarchive clean archive
- name: Export ipa
run: |
cd cbreez
xcodebuild -exportArchive -archivePath build-output/app.xcarchive -exportPath build-output/ios -exportOptionsPlist ios/ExportOptions.plist
- name: Publish iOS Artefacts
uses: actions/upload-artifact@v1
with:
name: release-ios
path: cbreez/build-output/ios
- name: Publish to Testflight
run: |
altool="$(dirname "$(xcode-select -p)")/Developer/usr/bin/altool"
ipa="$PWD/cbreez/build-output/ios/c_breez.ipa"
"$altool" --upload-app --type ios --file "$ipa" --username $TESTFLIGHT_USERNAME --password $TESTFLIGHT_PASSWORD