Deploying Flutter Application with Github Actions (PlayStore)

Search for a command to run...

No comments yet. Be the first to comment.
The Problem Wasn’t Triage Most AI workflows in software engineering still keep the human directly in the middle of triage. The AI might help write code. It might explain a stack trace. It might summar

There’s been a steady undercurrent of people switching tools lately. Copilot to Claude. Claude to something else. Codex quietly entering more workflows. A lot of confidence in different directions, of

It’s been said to me that at times my responses can come across as a “no” first-unintentionally, of course, but real all the same. Not long ago, someone on my team shared an idea they were exploring. I began with a caution, meaning to help them avoid...

The opening sentence of any message often carries more weight than everything that follows. I’ve learned this the hard way. Recently, a report shared something he wanted to pursue. I was supportive — I really was — but my first response came as a cau...

One of the things I’ve always been comfortable with is admitting when I don’t know something. To me, it’s one of the real distinctions between the more and less experienced engineers — and honestly, people in general. When you’re earlier in your care...

stackbit_url_path: posts/deploy-flutter-app-playsotre-github-actions title: "Deploying Flutter Application with Github Actions (PlayStore)" date: '2023-06-19T09:00:00.000Z' excerpt: >- tags:
As Flutter continues to gain popularity among developers, the need for efficient and streamlined deployment processes has become paramount. One powerful tool that can help in this regard is Github Actions, a continuous integration and continuous delivery (CI/CD) platform provided by GitHub. In this guide, we will explore how to deploy a Flutter application using Github Actions, step by step. We will cover everything from setting up the workflow to signing and deploying the app on the Play Store.
To start leveraging the power of Github Actions for deploying your Flutter application, you need to enable it for your repository. Once enabled, you can add a workflow file that defines the steps and actions to be performed during the deployment process.
.github/workflows directory at the root of your project..github/workflows directory, create a file named build.yml.build.yml file:# Name of the workflow
name: Build
# Controls what will trigger the workflow. Change it to your needs.
on:
# A new push to the "main" branch.
push:
branches: [ "main" ]
# A new pull request to the "main" branch.
pull_request:
branches: [ "main" ]
# Allows to trigger the workflow from GitHub interfaces.
workflow_dispatch:
# A single workflow can have multiple jobs.
jobs:
# 'A new job is defined with the name: "build_android"
build_android:
# Defines what operating system will be used for the actions.
# For android, we will use Linux GitHub-Hosted Runner.
runs-on: ubuntu-22.04
# Defines what step should be passed for successful run
steps:
# Checkout to the selected branch
- name: Checkout
uses: actions/checkout@v3
# Download and install flutter packages
- name: Install Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: "3.10.0" # Change to the version you use in your project
Make sure to customize the workflow file according to your project's specific needs, such as branch names and Flutter versions.
Once you have set up the workflow, the next step is to build your Flutter application and generate an unsigned App Bundle. The App Bundle is a publishing format that contains all the compiled code and resources of your app, optimized for distribution on the Google Play Store.
To build the app and generate the unsigned App Bundle, follow these steps:
./android/app/build.gradle.# Build release app bundle
- name: Build release app bundle
run: flutter build appbundle
This command will build the app and generate an unsigned App Bundle in the output directory of your project. This step ensures that every time you push a new commit, a new unsigned App Bundle is generated.
Before you can deploy your app to the Play Store, you need to sign the App Bundle with a signing key. Signing the app bundle ensures the integrity and authenticity of your app.
To sign the App Bundle, follow these steps:
keytool command. This key will be used to sign the App Bundle. For example:keytool -genkey -v -keystore mykey.keystore -alias mykey -keyalg RSA -keysize 2048 -validity 10000
base64 -i ./mykey.keystore -o ./keystore-base64.txt
# Sign App Bundle
- name: Sign App Bundle
uses: r0adkll/sign-android-release@v1
id: sign_app
with:
releaseDirectory: build/app/outputs/bundle/release/
signingKeyBase64: ${{ secrets.KEYSTORE_BASE64 }}
alias: ${{ secrets.KEY_ALIAS }}
keyStorePassword: ${{ secrets.KEYSTORE_PASSWORD }}
keyPassword: ${{ secrets.KEY_PASSWORD }}
Replace the secret names (KEYSTORE_BASE64, KEY_ALIAS, KEYSTORE_PASSWORD, KEY_PASSWORD) with the respective secrets you added to your repository.
Now that you have a signed App Bundle, you can proceed with deploying your Flutter app to the Play Store. The Play Store is the primary distribution platform for Android apps.
To deploy the app to the Play Store, follow these steps:
# Upload to Play Store (Internal Testing)
- name: Upload to Play Store (Internal Testing)
uses: r0adkll/upload-google-play@v1.0.18
with:
serviceAccountJsonPlainText: ${{ secrets.SERVICE_ACCOUNT_JSON }}
packageName: com.example.app
releaseFiles: ${{ steps.sign_app.outputs.signedReleaseFile }}
mappingFile: ./build/app/outputs/mapping/release/mapping.txt
track: internal
Replace com.example.app with your app's package name and SERVICE_ACCOUNT_JSON with the name of the secret containing the service account JSON.
In this comprehensive guide, we have covered the process of deploying a Flutter application using Github Actions. From enabling Github Actions and setting up the workflow to signing the app bundle and deploying it to the Play Store and App Store, we have explored the entire deployment pipeline. By leveraging the power of Github Actions, you can automate and streamline your deployment process, saving time and effort. We hope this guide has provided you with the knowledge and tools to successfully deploy your Flutter app with ease. Happy deploying!