Azure and Flutter, release pipeline

Azure and Flutter, release pipeline

How to deploy a flutter application to google and Apple stores.

Hello, my name is Rodrigo and I would like to share a pipeline that I built using azure to deploy a release version of one application that I'm working with azure.

At first, I found some difficulties to find examples of how to deploy to stores using Azure, all the examples are for, just to build the bundle or deploy to something like Microsoft app centre.

This pipeline has a lot to improve but, it works for now.

1. Declare the image.

As we are building for iOS too, we need to use a Mac machine, to declare the vm:

1.png

2. Install Flutter.

Your azure probably will not have the flutter extension installed, so you just need to go here, and install it on your Azure account, in case that you are not an admin you need to wait them approve the solicitation.

2.png

3. Upload your files to a secure folder.

Go to: Pipelines → Library → Secure files

Here you upload the files that you need to be secure, after the process you can make them secure, so anyone can change it.

Use:

To export the p12 and the provisioning certificate, here

To export your playStore.json file, here.

To generate your jks certificate, here.

  1. ios.p12
  2. pc-api.json
  3. key.jks
  4. appStore.mobileprovision

4. Download the Google Play Store API JSON credential file.

Here you will download the Google play credential that you have uploaded to secure files

3.png

5. Change Java version to 11.

In case that your project uses Java version 11, you need to add this step. I think this will happen if you are using the latest version of Gradle.

1*R67IqGBUhn2nW4tbNVERHg.png

6. Download and install p12.

Download and install your.p12 certificate that you have uploaded to secure files

Here I'm using the $(certpassword) to store the certificate installation password.

6.png

7. Install provisioning profile.

7.png

8. Build Android app bundle.

Now that we have set up all our certificates and installed you can start to build the bundles, I have chosen to build separated bundles, so after I can break the pipeline with smaller pieces to run different pipelines without needing to repeat code.

8.png

I'm using the flag - obfuscate to difficult reverse engineering, reference

9. Sign your app bundle.

9.png

apkFiles: Is to set where the generated bundle file is located, you can pass AAB files and APK files. I'm using the - min-sdk-version 21 because for some reason the AndroidSigning task does not identify the min SDK version on Gradle file.

Also, all the variables for keyStorePassword, alias, and keyPassword, are variables that were set like certpassword.

10. Deploy the app bundle to play store.

I'm uploading the app to the internal track, so we can test it first before deploying to production lane. Also keep attention to serviceAccountKey is the path where you downloaded the secure file of Google Play Store credential, this variable is filled automatically after the download.

10.png

11. Build iOS workspace.

11.png

12. Archive and export the IPA.

Here you need to get your teamId at apple connect website

APPLE_CERTIFICATE_SIGNING_IDENTITY

APPLE_PROV_PROFILE_UUID

Are both variables that will be set automatically after you install p12 and provisioning certificates.

$(configuration) → Release $(SDK) → iphoneos

13.png

13. Deploy to apple connect.

Use this method to generate the API key To get your apitoken, you need to download the p8 file after you create your API key at Apple Store connect and encrypt it using base 64 algorithms.

Just paste the content of the file here, add the result on a variable on Azure to use as credential with fast lane while deploying the IPA.

Also, deploying the app to TestFlight to test before deploying to production.

As I mention before the pipeline has improvements to be made but at the moment is way better than generate the bundle manually.

13.png

14. Trigger

You can add a trigger for your pipeline, in my case, every time that a push occurs on master branch the pipeline will start.

14.png

Thank you. I hope this post help you find content that I had a hard time to find. Be safe.

#azure, #ci, #flutter, #pipeline, #cd, #android, #ios, #mobile, #release

Did you find this article valuable?

Support Rodrigo Martins by becoming a sponsor. Any amount is appreciated!