Follow continuous delivery (CD) best practices with Flutter to ensure that your application is delivered to your beta testers and tested on a regular basis without the need for manual manipulation.
fastlane
This tutorial shows you how to integrate fastlane, an open source toolkit, into existing test and continuous integration (CI) workflows such as Travis or Cirrus.
Local setup It is
highly recommended to test the build and deployment process locally before moving to the cloud. You can also implement continuous deployment from your local machine.
- Install fastlane:
gem install fastlane
orbrew install fastlane
. For more detailed information visit Fastlane documentation . - Create a Flutter project and when ready, make sure your project builds with
-
flutter build appbundle
; and -
flutter build ios --release --no-codesign
...
-
- Initialize Fastlane projects for each platform.
-
fastlane init
[project]/android
. -
fastlane init
[project]/ios
.
-
- ,
Appfile
.
- ,
package_name
[project]/android/fastlane/Appfile
AndroidManifest.xml
. - ,
[project]/ios/fastlane/Appfile
Info.plist
.apple_id
,itc_team_id
,team_id
.
- ,
- .
- Supply ,
fastlane supply init
Play Store . .json - . - ITunes Connect
Appfile
apple_id
.FASTLANE_PASSWORD
iTunes Connect. iTunes/TestFlight.
- Supply ,
- .
- Android : . .apk, « ». « » .aab/.apk, Play Store, Play Store.
- , . . Play Store.
- .
- gradle release,
android.buildTypes.release
[project]/android/app/build.gradle
.
- iOS, TestFlight App Store, , .
- Apple Developer Account.
-
[project]/ios/Runner.xcworkspace/
.
- Android : . .apk, « ». « » .aab/.apk, Play Store, Play Store.
-
Fastfile
.
- For Android, follow the Fastlane Android beta deployment guide . All editing can be just an addition
lane
that callsupload_to_play_store
. Set the argumentaab
to../build/app/outputs/bundle/release/app-release.aab
to use a package that hasflutter build
already been prepared. - For iOS, follow the Fastlane iOS beta deployment guide . All editing can be as simple as adding
lane
, which callsbuild_ios_app
withexport_method: 'app-store'
andupload_to_testflight
. On iOS, an additional build will be required, since itflutter build
builds.app
rather than archives.ipas
for release.
- For Android, follow the Fastlane Android beta deployment guide . All editing can be just an addition
You are now ready to deploy locally or migrate your deployment to a continuous integration (CI) system.
Deploying Locally
- release.
-
flutter build appbundle
. -
flutter build ios --release --no-codesign
. , fastlane .
-
- Fastfile .
-
cd android
,fastlane [ lane]
. -
cd ios
,fastlane [ lane]
.
-
First, follow the instructions in the local setup section described in the Local setup section to make sure the process is working correctly before moving to a cloud system like Travis.
The main thing to note is that since cloud instances are ephemeral and unreliable, you shouldn't leave your credentials, such as the JSON of the Play Store service account or the iTunes distribution certificate, on the server.
Continuous Integration (CI) systems like Cirrus typically support encrypted environment variables for storing private data.
Take all precautions not to print the values of these variables to the console in your test scripts. These variables should also not be available in pull requests until they are merged so that attackers cannot create a pull request that will steal these secrets. Be careful when interacting with these secrets in pull requests that you accept and merge.
- Make credentials ephemeral.
- On Android:
- Remove the field
json_key_file
fromAppfile
and store the contents of the JSON string in an encrypted variable in your CI system. Use the argumentjson_key_data
inupload_to_play_store
to read the environment variable directly into yourFastfile
. - (, base64) . CI
-
echo "$PLAY_STORE_UPLOAD_KEY" | base64 --decode > /home/cirrus/[directory # , gradle].keystore
- Remove the field
- iOS:
-
FASTLANE_PASSWORD
CI. - CI . Fastlane Match .
-
- On Android:
- Gemfile
gem install fastlane
CI, fastlane . .
-
[project]/android
[project]/ios
Gemfile, : -
source "https://rubygems.org" gem "fastlane"
-
bundle update
Gemfile.
Gemfile.lock
. -
bundle exec fastlane
fastlane
.
-
- CI,
.travis.yml
.cirrus.yml
, .
- Linux macOS.
- Xcode macOS (, o
sx_image: xcode9.2
). - . Fastlane CI CI.
- , , , :
- Bundler
gem install bundler
. - Android , Android SDK
ANDROID_SDK_ROOT
. -
bundle install
[project]/android
[project]/ios
. - , Flutter SDK
PATH
.
- Bundler
- CI:
-
flutter build appbundle
flutter build ios --release --no-codesign
, . cd android
cd ios
bundle exec fastlane [ lane]
. Cirrus Flutter.
, .
-