Skip to content

Build & Deploy iOS Production to TestFlight #19

Build & Deploy iOS Production to TestFlight

Build & Deploy iOS Production to TestFlight #19

name: Build & Deploy iOS Production to TestFlight
on:
workflow_dispatch:
jobs:
build:
runs-on: macOS-13
steps:
- uses: actions/checkout@v4
- name: JSON to variables
uses: antifree/[email protected]
with:
filename: 'config/release_version.json'
- uses: subosito/flutter-action@v2
with:
flutter-version: '3.19.6'
channel: 'stable'
cache: true
- name: Install dependencies
run: flutter pub get
- name: Install the Apple certificate and provisioning profile
env:
P12_DISTRIBUTION_CERTIFICATE_BASE64: ${{ secrets.IOS_P12_BASE64 }}
P12_DISTRIBUTION_CERTIFICATE_PASSWORD: ${{ secrets.IOS_CERTIFICATE_PASSWORD }}
DISTRIBUTION_PROVISIONING_PROFILE_BASE64: ${{ secrets.IOS_PROD_MOBILE_PROVISION_BASE64 }}
KEYCHAIN_PASSWORD: ${{ secrets.IOS_KEYCHAIN_PASSWORD }}
run: |
# create variables
CERTIFICATE_PATH=$RUNNER_TEMP/build_certificate.p12
PROVISIONING_PROFILE_PATH=$RUNNER_TEMP/build_pp.mobileprovision
KEYCHAIN_PATH=$RUNNER_TEMP/app-signing.keychain-db
# import certificate and provisioning profile from secrets
echo -n "$P12_DISTRIBUTION_CERTIFICATE_BASE64" | base64 --decode -o $CERTIFICATE_PATH
echo -n "$DISTRIBUTION_PROVISIONING_PROFILE_BASE64" | base64 --decode -o $PROVISIONING_PROFILE_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 $CERTIFICATE_PATH -P "$P12_DISTRIBUTION_CERTIFICATE_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 $PROVISIONING_PROFILE_PATH ~/Library/MobileDevice/Provisioning\ Profiles
- name: Config demo user info
run: |
echo "demoServerUrl=$DEMO_SERVER_URL" >> assets/env/.env_demo
echo "demoUserName=$DEMO_USER_NAME" >> assets/env/.env_demo
echo "demoPassword=$DEMO_PASSWORD" >> assets/env/.env_demo
env:
DEMO_SERVER_URL: ${{ secrets.KEY_DEMO_SERVER_URL }}
DEMO_USER_NAME: ${{ secrets.KEY_DEMO_USER_NAME }}
DEMO_PASSWORD: ${{ secrets.KEY_DEMO_PASSWORD }}
- name: Building IPA
run: |
flutter build ipa \
--release \
--flavor prod \
--target lib/main.dart \
--export-options-plist=ios/Runner/ExportOptions.plist \
--build-name ${{ env.VersionName }} \
--build-number ${{github.run_number}}
- name: Clean up keychain and provisioning profile
if: ${{ always() }}
run: |
security delete-keychain $RUNNER_TEMP/app-signing.keychain-db
rm ~/Library/MobileDevice/Provisioning\ Profiles/build_pp.mobileprovision
- name: 'Upload app to TestFlight'
uses: apple-actions/upload-testflight-build@v1
with:
app-path: 'build/ios/ipa/axon_ivy.ipa'
issuer-id: ${{ secrets.IOS_APPSTORE_ISSUER_ID }}
api-key-id: ${{ secrets.IOS_APPSTORE_API_KEY_ID }}
api-private-key: ${{ secrets.IOS_APPSTORE_API_PRIVATE_KEY }}