Flutter.dev: Continuous delivery with Flutter

The translation of the article was prepared in anticipation of the start of the Flutter Mobile Developer course .










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.



  1. Install fastlane: gem install fastlaneor brew install fastlane. For more detailed information visit Fastlane documentation .
  2. Create a Flutter project and when ready, make sure your project builds with

    • flutter build appbundle; and
    • flutter build ios --release --no-codesign...
  3. Initialize Fastlane projects for each platform.

    • fastlane init [project]/android.
    • fastlane init [project]/ios.
  4. , Appfile .

    • , package_name [project]/android/fastlane/Appfile AndroidManifest.xml.
    • , [project]/ios/fastlane/Appfile Info.plist. apple_id, itc_team_id, team_id .
  5. .

    • Supply , fastlane supply init Play Store . .json - .
    • ITunes Connect Appfile apple_id. FASTLANE_PASSWORD iTunes Connect. iTunes/TestFlight.
  6. .

    • Android : . .apk, « ». « » .aab/.apk, Play Store, Play Store.

      • , . . Play Store.
      • .
      • gradle release, android.buildTypes.release [project]/android/app/build.gradle.
    • iOS, TestFlight App Store, , .



  7. Fastfile .



    • For Android, follow the Fastlane Android beta deployment guide . All editing can be just an addition lanethat calls upload_to_play_store. Set the argument aabto ../build/app/outputs/bundle/release/app-release.aabto use a package that has flutter buildalready been prepared.
    • For iOS, follow the Fastlane iOS beta deployment guide . All editing can be as simple as adding lane, which calls build_ios_appwith export_method: 'app-store'and upload_to_testflight. On iOS, an additional build will be required, since it flutter buildbuilds .apprather than archives .ipasfor release.


You are now ready to deploy locally or migrate your deployment to a continuous integration (CI) system.



Deploying Locally



  1. release.

    • flutter build appbundle.
    • flutter build ios --release --no-codesign. , fastlane .
  2. 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.



  1. Make credentials ephemeral.

    • On Android:



      • Remove the field json_key_filefrom Appfileand store the contents of the JSON string in an encrypted variable in your CI system. Use the argument json_key_datain upload_to_play_storeto read the environment variable directly into your Fastfile.
      • (, base64) . CI
      • echo "$PLAY_STORE_UPLOAD_KEY" | base64 --decode > /home/cirrus/[directory #   ,    gradle].keystore
    • iOS:



      • FASTLANE_PASSWORD CI.
      • CI . Fastlane Match .
  2. 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.
  3. CI, .travis.yml .cirrus.yml, .



    • Linux macOS.
    • Xcode macOS (, osx_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.
    • CI:



      • flutter build appbundle flutter build ios --release --no-codesign, .
      • cd android cd ios
      • bundle exec fastlane [ lane]






      . Cirrus Flutter.





      , .








All Articles