Skip to content

Instantly share code, notes, and snippets.

@heyhey1028
Last active February 25, 2024 05:41
Show Gist options
  • Save heyhey1028/fc8f999cc197373404ef0614d0063e25 to your computer and use it in GitHub Desktop.
Save heyhey1028/fc8f999cc197373404ef0614d0063e25 to your computer and use it in GitHub Desktop.
Continuous delivery of flutter app (Fastlane + Github Actions + Firebase App Distribution) -- flutter build ios ---

created 2022/10/12

Continuous Delivery of Flutter test app

About

A sample code for distributing test ios app built with flutter via Firebase App Distribution with one tap of github actions. Sample is dedicated for circumstances using below.

  • flutter
  • fastlane
  • github actions
  • Firebase App Distribution

You can use the code by copy and paste, after preparing the prerequisites and environmental variables introduced below.

Prerequisits

Whom using the sample is expected to have done below using the code

  • manages flutter version with fvm
  • manages flavors for flutter project
  • manages iOS certificates and provisioning profiles with fastlane match
  • have activated firebase project and app distribution for the app

Environment variables you need to prepare

  • MATCH_PASSWORD: passphrase you specified at first run of fastlane match reference
  • FIREBASE_TOKEN: token generated by firebase login:ci command reference
  • PERSONAL_TOKEN: personal access token of whom has access authorization to repository used by fastlane match reference

Notes

flutter also supports flutter build ipa command which can shorten the execution time up to half of workflow introduced here. I have introduced sample using flutter build ipa in https://gist.github.com/heyhey1028/5d14b22aa2990e1253c95d356a2d0fed

References

Please leave a comment if you have any trouble trying to reference the code. Also pressing a star would help me motivated in creating sample codes. Thanks!!

name: App distribution
on:
workflow_dispatch
jobs:
ios:
runs-on: macos-latest
timeout-minutes: 60
env:
MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }}
FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}
PERSONAL_TOKEN: ${{ secrets.PERSONAL_TOKEN }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 10
- name: Get flutter version from fvm
uses: kuhnroyal/flutter-fvm-config-action@v1
- name: Install flutter
uses: subosito/flutter-action@v2
with:
flutter-version: ${{ env.FLUTTER_VERSION }}
channel: ${{ env.FLUTTER_CHANNEL }}
cache: true
cache-key: flutter
cache-path: ${{ runner.tool_cache }}/flutter
- name: Install Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.1
bundler-cache: true
- name: Setup Xcode
uses: maxim-lobanov/setup-xcode@v1.4.1
with:
xcode-version: latest-stable
- name: instal firebase cli
run: npm install -g firebase-tools
- name: Build Runner
run: flutter build ios --target lib/main_dev.dart --release --no-codesign --flavor Dev
- name: Bundle install fastlane
run: cd ios && bundle install
- name: Distribute by App Distribution
run: cd ios && bundle exec fastlane app_distribution_dev
# This file contains the fastlane.tools configuration
# You can find the documentation at https://docs.fastlane.tools
#
# For a list of all available actions, check out
#
# https://docs.fastlane.tools/actions
#
# For a list of all available plugins, check out
#
# https://docs.fastlane.tools/plugins/available-plugins
#
# Uncomment the line if you want fastlane to automatically update itself
# update_fastlane
default_platform(:ios)
platform :ios do
desc "upload AppDistribution DEV"
lane :app_distribution_dev do
ENV['MATCH_KEYCHAIN_NAME'] = 'TempKeychain'
ENV['MATCH_KEYCHAIN_PASSWORD'] = 'TempKeychainPassword'
create_keychain(
name: ENV['MATCH_KEYCHAIN_NAME'],
password: ENV['MATCH_KEYCHAIN_PASSWORD'],
timeout: 1800
)
match(type: "adhoc", readonly: true)
gym(
workspace: 'Runner.xcworkspace',
scheme: 'Dev',
clean: true,
output_directory: './build/Dev',
export_method: 'ad-hoc'
)
firebase_app_distribution(
app: <YOUR FIREBASE APP ID>, (ex. 1:xxxxxxxxxxxx:ios:xxxxxxxxxxxxxxxxxxxx)
ipa_path: './build/Dev/Runner.ipa',
testers: [<YOUR TESTER EMAIL ADDRESS>]
)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment