Skip to content

v3.1.0-beta01

v3.1.0-beta01 #32

Workflow file for this run

name: Build iOS App
on:
workflow_dispatch:
release:
types: [ published ]
jobs:
build_with_signing:
runs-on: macos-latest
steps:
# Checkout the repo
- name: Checkout repository
uses: actions/checkout@v4
# Install the Apple certificate and provisioning profile
- name: Install the Apple certificate and provisioning profile
env:
BUILD_CERTIFICATE_BASE64: ${{ secrets.APPLE_DISTRIBUTION_CERT }}
P12_PASSWORD: ${{ secrets.P12_PASSWORD }}
BUILD_PROVISION_PROFILE_BASE64: ${{ secrets.PROVISIONING_PROFILE_BASE64 }}
KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }}
run: |
# create variables
BUILD_CERT_PATH=$RUNNER_TEMP/build_certificate.p12
PP_PATH=$RUNNER_TEMP/FlutterAppStoreProfileWithPush.mobileprovision
KEYCHAIN_PATH=$RUNNER_TEMP/app-signing.keychain-db
# import certificate and provisioning profile from secrets
echo -n "$BUILD_CERTIFICATE_BASE64" | base64 --decode -o $BUILD_CERT_PATH
echo -n "$BUILD_PROVISION_PROFILE_BASE64" | base64 --decode -o $PP_PATH
# create temporary keychain
security create-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
security set-keychain-settings -lut 21600 $KEYCHAIN_PATH
security unlock-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
# import certificate to keychain
security import $BUILD_CERT_PATH -P "$P12_PASSWORD" -A -t cert -f pkcs12 -k $KEYCHAIN_PATH
security list-keychain -d user -s $KEYCHAIN_PATH
# apply provisioning profile
mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles
cp $PP_PATH ~/Library/MobileDevice/Provisioning\ Profiles
# Create p8 Auth Key from secrets
- name: Create p8 Auth Key
env:
APP_STORE_CONNECT_KEY: ${{ secrets.APP_STORE_CONNECT_KEY }}
APP_STORE_KEY_ID: ${{ secrets.APP_STORE_KEY_ID }}
run: |
# Create private_keys folder
KEY_PATH=$GITHUB_WORKSPACE/example/build/ios/ipa/private_keys
mkdir -p $KEY_PATH
AUTH_KEY_PATH=$KEY_PATH/AuthKey_$APP_STORE_KEY_ID.p8
# import certificate and provisioning profile from secrets
echo -n "$APP_STORE_CONNECT_KEY" | base64 --decode -o $AUTH_KEY_PATH
# Install Flutter SDK
- name: Install Flutter
uses: subosito/flutter-action@v2
with:
channel: "stable"
architecture: x64
# Get package dependencies and generate files
- name: Get package dependencies and generate files
run: |
flutter pub get
flutter pub run build_runner build --delete-conflicting-outputs
# Get example app dependencies and generate files
- name: Get example app dependencies and generate files
working-directory: example
run: |
flutter pub get
flutter pub run build_runner build --delete-conflicting-outputs
# Build ios example app
- name: Build ios example app
working-directory: example
env:
PROJECT_ID: ${{ secrets.PROJECT_ID }}
APP_STORE_KEY_ID: ${{ secrets.APP_STORE_KEY_ID }}
APPLE_ISSUER_ID: ${{ secrets.APPLE_ISSUER_ID }}
run: |
# Get app version from file
FILE_VALUE=`cat $GITHUB_WORKSPACE/lib/version.dart`
VERSION=`echo $FILE_VALUE | sed "s/[^']*'\([^']*\)'.*/\1/"`
# Build ios app with flutter
flutter build ios --build-name $VERSION --dart-define="PROJECT_ID=$PROJECT_ID" --config-only --release
cd ios
agvtool new-marketing-version $VERSION
agvtool next-version -all
# Archive and export
xcodebuild -workspace "$GITHUB_WORKSPACE/example/ios/Runner.xcworkspace" -scheme Runner -sdk iphoneos -destination generic/platform=iOS -archivePath "$GITHUB_WORKSPACE/example/ios/Runner.xcarchive" archive
xcodebuild -exportArchive -allowProvisioningUpdates -sdk iphoneos -archivePath "$GITHUB_WORKSPACE/example/ios/Runner.xcarchive" -exportOptionsPlist "$GITHUB_WORKSPACE/example/ios/Runner/ExportOptionsRelease.plist" -exportPath "$GITHUB_WORKSPACE/example/build/ios/ipa" -authenticationKeyIssuerID $APPLE_ISSUER_ID -authenticationKeyID $APP_STORE_KEY_ID -authenticationKeyPath "$GITHUB_WORKSPACE/example/build/ios/ipa/private_keys/AuthKey_$APP_STORE_KEY_ID.p8"
# Upload IPA to Testflight
- name: Upload IPA to Testflight
working-directory: example/build/ios/ipa
env:
APPLE_ISSUER_ID: ${{ secrets.APPLE_ISSUER_ID }}
APP_STORE_KEY_ID: ${{ secrets.APP_STORE_KEY_ID }}
run: xcrun altool --upload-app --type ios -f web3modal_flutter.ipa --apiKey $APP_STORE_KEY_ID --apiIssuer $APPLE_ISSUER_ID
- name: Notify Channel
uses: slackapi/[email protected]
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
SLACK_WEBHOOK_TYPE: 'INCOMING_WEBHOOK'
with:
payload: |-
{
"text":"New iOS Example app for Web3Modal Flutter ${{ github.event.release.name }} was just deployed."
}
# Clean up
- name: Clean up
if: ${{ always() }}
run: |
security delete-keychain $RUNNER_TEMP/app-signing.keychain-db
rm ~/Library/MobileDevice/Provisioning\ Profiles/FlutterAppStoreProfileWithPush.mobileprovision
flutter clean
cd example
flutter clean