Flutter apps

From a Git repository to Google Play and the App Store, step by step. No pipeline to write.

AppRelease builds with the settings you enter in the console. An apprelease.yaml in the repository is optional, for teams that want to change how the app is built; everything below the first two sections is about that file.

Adding the app to AppRelease

Open Applications → Add application. The wizard has three short steps:

  1. Repository: the Git address of the Flutter project (for example https://github.com/acme/shop-app) and the branch to build.
  2. Details: the app's name and the Flutter version (stable is right for most projects).
  3. Stores: Google Play, the App Store, or both, with the Android package name and the iOS bundle identifier exactly as the stores know them.

Then add the credentials the chosen stores need under Credentials (the sections below show where each one comes from), and press Publish on the app. The dashboard's launch plan lists the same steps in order and opens each form.

Files that are not in Git. If the project needs a file the repository leaves out, such as Firebase's android/app/google-services.json or ios/Runner/GoogleService-Info.plist, or a .env, add it under Credentials → Build file with its path. The runner writes it into the checkout before every build. A build that fails with "google-services.json is missing" needs exactly this.

apprelease.yaml, if you want it

Without the file, a release does what the console says: check out the branch, fetch the next build number from the store, build, sign with the credentials linked to the app and upload to the track you chose. Add apprelease.yaml to the root of the repository only to change that: extra scripts, a different Flutter version, several workflows, release notes, beta groups.

Tip The app's Config tab shows the file the console would write for the current settings and credentials. Copy it, commit it, and adjust from there; the reference names in it are the ones from Credentials.
workflows:
  android-workflow:
    name: Android workflow
    # ......
  ios-workflow:
    name: iOS workflow
    # ......

The runner picks the workflow whose id matches the platform and track (android-production), else one named after the platform (android, android-workflow), else the first one that signs for that platform.

Setting the Flutter version

The environment section chooses the Flutter channel or version the build uses. If nothing is specified, the version preinstalled on the runner is used.

workflows:
  sample-workflow:
    environment:
      flutter: stable
Note Possible values are stable, beta and master, or a specific version such as 3.41.2.

If the project uses Flutter Version Management, set flutter: fvm. The runner reads .fvmrc (or .fvm/fvm_config.json) and installs that version.

workflows:
  sample-workflow:
    environment:
      flutter: fvm

Code signing

All applications have to be digitally signed before they can be published, to confirm their author and guarantee the code has not been altered since it was signed.

Generating a keystore

Create a keystore for signing release builds with the Java keytool utility:

keytool -genkey -v -keystore apprelease.keystore -storetype JKS \
        -keyalg RSA -keysize 2048 -validity 10000 -alias apprelease

Keytool asks for a password for the keystore and the key alias, and for some information about you and your organisation. Note the keystore password, the key alias and the key password; you need them in the next step.

Uploading a keystore

  1. In the console open Credentials → Add credential → Android keystore.
  2. Pick the keystore file.
  3. Enter the keystore password, the key alias and the key password. They are checked against the file before saving.
  4. Choose the application it signs, or leave it shared.
  5. The reference name is filled in for you. It is the name apprelease.yaml uses, if you write that file; the file's own name is not.
  6. Click Save.
Note An uploaded keystore cannot be downloaded again. Keep your own copy somewhere safe: every future Google Play release has to be signed with the same key. Keep the file private and never commit it to the repository.

Referencing keystores in apprelease.yaml

To have AppRelease fetch the keystore during the build, list its reference name under android_signing in the environment section:

workflows:
  android-workflow:
    name: Android workflow
    # ....
    environment:
      android_signing:
        - keystore_reference

These environment variables are set by AppRelease for the build:

VariableValue
AR_KEYSTORE_PATHWhere the keystore was written on the runner
AR_KEYSTORE_PASSWORDKeystore password
AR_KEY_ALIASKey alias
AR_KEY_PASSWORDKey alias password

Signing Android apps using Gradle

To sign the app, modify android/app/build.gradle or android/app/build.gradle.kts:

...
android {
    ...
    defaultConfig { ... }
    signingConfigs {
        release {
            if (System.getenv()["CI"]) { "c">// CI=true is exported by AppRelease
                storeFile file(System.getenv()["AR_KEYSTORE_PATH"])
                storePassword System.getenv()["AR_KEYSTORE_PASSWORD"]
                keyAlias System.getenv()["AR_KEY_ALIAS"]
                keyPassword System.getenv()["AR_KEY_PASSWORD"]
            } else {
                keyAlias keystoreProperties['keyAlias']
                keyPassword keystoreProperties['keyPassword']
                storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
                storePassword keystoreProperties['storePassword']
            }
        }
    }
    buildTypes {
        release {
            ...
            signingConfig signingConfigs.release
        }
    }
}
...
...
android {
    ...
    defaultConfig { ... }
    signingConfigs {
        create("release") {
            if (System.getenv("CI") != null) { "c">// CI=true is exported by AppRelease
                storeFile = file(System.getenv("AR_KEYSTORE_PATH"))
                storePassword = System.getenv("AR_KEYSTORE_PASSWORD")
                keyAlias = System.getenv("AR_KEY_ALIAS")
                keyPassword = System.getenv("AR_KEY_PASSWORD")
            } else {
                keyAlias = keystoreProperties["keyAlias"] as String?
                keyPassword = keystoreProperties["keyPassword"] as String?
                storeFile = (keystoreProperties["storeFile"] as String?)?.let { file(it) }
                storePassword = keystoreProperties["storePassword"] as String?
            }
        }
    }
    buildTypes {
        getByName("release") {
            ...
            signingConfig = signingConfigs.getByName("release")
        }
    }
}
...

Creating the App Store Connect API key

Signing iOS applications requires Apple Developer Program membership.

It is recommended to create a dedicated App Store Connect API key for AppRelease in App Store Connect:

  1. Log in to App Store Connect and go to Users and Access → Integrations → App Store Connect API.
  2. Click the + sign to generate a new API key.
  3. Enter a name for the key and choose an access level. App Manager is enough to sign, upload and submit.
  4. Click Generate.
  5. As soon as the key is generated it appears in the list of active keys. Click Download API Key to save the private key (.p8). It can only be downloaded once.
Take note of the Issuer ID above the table and the Key ID of the generated key; both are needed in the next step.

Adding the App Store Connect API key to AppRelease

  1. In the console open Credentials → Add credential → App Store Connect API key.
  2. Pick the .p8 file.
  3. Enter the Key ID and the Issuer ID.
  4. Click Save.

Automatic vs manual code signing

With the API key in place, automatic signing is the simplest option: AppRelease creates or fetches the distribution certificate and the provisioning profile for the bundle identifier before the build. Add this to the environment section:

workflows:
  ios-workflow:
    name: iOS workflow
    # ....
    environment:
      ios_signing:
        distribution_type: app_store   # app_store | ad_hoc | development
        bundle_identifier: com.example.app

Manual signing with a .p12 and a .mobileprovision is not needed and not supported: the API key covers App Store, ad hoc and development builds.

Either way, the runner writes an export options plist and exposes its path as AR_EXPORT_OPTIONS for the build command.

Configure scripts to build the app

Add scripts to prepare the environment and start the build. Each script has a name shown in the log and a shell snippet. In this step you also declare the artifacts you are interested in; they are available for download when the build finishes and are what the publishing step uploads.

    scripts:
      - name: Set up local.properties
        script: |
          echo "flutter.sdk=$HOME/programs/flutter" > "$AR_BUILD_DIR/android/local.properties"
      - name: Get Flutter packages
        script: |
          flutter pub get
      - name: Build AAB with Flutter
        script: |
          flutter build appbundle --release
    artifacts:
      - build/**/outputs/**/*.aab
      - build/**/outputs/**/mapping.txt
Note To build an .apk instead, replace the build command with flutter build apk --release and the artifact pattern with build/**/outputs/**/*.apk.
    scripts:
      - name: Get Flutter packages
        script: |
          flutter pub get
      - name: Install CocoaPods dependencies
        script: |
          cd ios && pod install
      - name: Build ipa with Flutter
        script: |
          flutter build ipa --release \
            --export-options-plist=$AR_EXPORT_OPTIONS
    artifacts:
      - build/ios/ipa/*.ipa
      - /tmp/xcodebuild_logs/*.log

Build versioning

Every artifact uploaded to Google Play or App Store Connect must carry a build number higher than the last one. AppRelease automates this: with a versioning section, the latest build number is fetched from the store before the scripts run and the next one is exposed as AR_BUILD_NUMBER.

Google Play is queried with the service account used for publishing, so set that up first (see Google Play publishing). Then:

workflows:
  android-workflow:
    # ....
    environment:
      groups:
        - google_play
      vars:
        PACKAGE_NAME: "com.example.app"
    versioning:
      source: google_play
      tracks: [internal, alpha, beta, production]
    scripts:
      - name: Build AAB with Flutter
        script: |
          flutter build appbundle --release \
            --build-name=1.0.$AR_BUILD_NUMBER \
            --build-number=$AR_BUILD_NUMBER

App Store Connect is queried with the API key named in ios_signing or publishing:

workflows:
  ios-workflow:
    # ....
    versioning:
      source: app_store_connect
    scripts:
      - name: Build ipa with Flutter
        script: |
          flutter build ipa --release \
            --build-name=1.0.$AR_BUILD_NUMBER \
            --build-number=$AR_BUILD_NUMBER \
            --export-options-plist=$AR_EXPORT_OPTIONS
Note With source: manual, or no versioning section, AR_BUILD_NUMBER is the number of the release in AppRelease (1, 2, 3 …). Set the version yourself in the build command if that is not what you want.

Publishing

AppRelease publishes to Google Play, App Store Connect (TestFlight and App Store) and by email. For the full set of options see Google Play and App Store Connect.

Email publishing

If the build finishes successfully, the release notes (if any) and the artifacts are sent to the recipients. If the build fails, an email with a link to the log is sent instead. Set success or failure to false to turn one of them off.

workflows:
  sample-workflow:
    environment:
      # ...
    scripts:
      # ...
    publishing:
      email:
        recipients:
          - user_1@example.com
          - user_2@example.com
        notify:
          success: true
          failure: false

Publishing to Google Play and App Store

Publishing to Google Play requires a service account in Google Play Console whose JSON key is stored as a secret environment variable, as described in Google Play publishing. Then you only need to provide the credentials and the track. If the app is still in draft status, include submit_as_draft: true or promote the app in Google Play first.

    publishing:
      google_play:
        credentials: $GOOGLE_PLAY_SERVICE_ACCOUNT
        track: internal
        submit_as_draft: true

Publishing to App Store Connect uses the API key added under Integrations. submit_to_testflight uploads the build and, optionally, adds it to beta groups; submit_to_app_store also creates the App Store version and submits it for review.

    publishing:
      app_store_connect:
        auth: integration
        submit_to_testflight: true
        beta_groups:
          - Beta testers
        submit_to_app_store: false

Conclusion

Having followed the steps above, you now have a working apprelease.yaml that builds, signs, versions and publishes the app. Save the file, commit it, open the app in the console and start a release to see it in action.

Your final apprelease.yaml should look something like this:

workflows:
  android-workflow:
    name: Android workflow
    max_build_duration: 60
    environment:
      android_signing:
        - keystore_reference
      groups:
        - google_play
      vars:
        PACKAGE_NAME: "com.example.app"
        GOOGLE_PLAY_TRACK: internal
      flutter: stable
    versioning:
      source: google_play
    scripts:
      - name: Set up local.properties
        script: |
          echo "flutter.sdk=$HOME/programs/flutter" > "$AR_BUILD_DIR/android/local.properties"
      - name: Get Flutter packages
        script: |
          flutter pub get
      - name: Build AAB with Flutter
        script: |
          flutter build appbundle --release \
            --build-name=1.0.$AR_BUILD_NUMBER \
            --build-number=$AR_BUILD_NUMBER
    artifacts:
      - build/**/outputs/**/*.aab
      - build/**/outputs/**/mapping.txt
    publishing:
      email:
        recipients:
          - user_1@example.com
        notify:
          success: true
          failure: false
      google_play:
        credentials: $GOOGLE_PLAY_SERVICE_ACCOUNT
        track: $GOOGLE_PLAY_TRACK
        submit_as_draft: true
workflows:
  ios-workflow:
    name: iOS workflow
    max_build_duration: 90
    instance_type: mac_m2
    environment:
      ios_signing:
        distribution_type: app_store
        bundle_identifier: com.example.app
      flutter: stable
      xcode: latest
    versioning:
      source: app_store_connect
    scripts:
      - name: Get Flutter packages
        script: |
          flutter pub get
      - name: Install CocoaPods dependencies
        script: |
          cd ios && pod install
      - name: Build ipa with Flutter
        script: |
          flutter build ipa --release \
            --build-name=1.0.$AR_BUILD_NUMBER \
            --build-number=$AR_BUILD_NUMBER \
            --export-options-plist=$AR_EXPORT_OPTIONS
    artifacts:
      - build/ios/ipa/*.ipa
      - /tmp/xcodebuild_logs/*.log
    publishing:
      email:
        recipients:
          - user_1@example.com
        notify:
          success: true
          failure: false
      app_store_connect:
        auth: integration
        submit_to_testflight: true
        beta_groups:
          - Beta testers
        submit_to_app_store: false

Next steps

This basic workflow is a complete release pipeline, but it is not the end of the road.

Add a flutter test step before the build so a red test never reaches the store. Look at triggering to start a release on every push to a branch or on a tag, and at environment variables for everything the runner exposes to your scripts.

Getting help and support

Email — support@apprelease.store, answered within a business day.
In the console — every failed release has a "Send to support" button that attaches the log.