This sample project allows you to leverage GitHub Actions to run common Flutter workflows. These are based on the workflows found in the Flutter Gallery repository. Continue reading to apply these to your Flutter project.
This is still in active development, and it currently supports iOS and Android deployments only. Please open a pull request to support other platforms.
Create workflows in your .github/workflows
directory. Examples are available in this repository. For more information, see the GitHub Help Documentation for Creating a workflow file.
Note: Although this Flutter project works as-is, consider tailoring these workflows to your needs. If you're starting from scratch, copying and pasting will work as long as you follow the GitHub flow and release based workflow.
Recommended rules for the main
and release/v*
branches:
- Require status checks to pass before merging
- Require branches to be up to date before merging
- Check security hardening
- Generate coverage report
- Run static testing
- Run unit testing
- Run widget testing
- All of the workflows here use the Ensure SHA Pinned Actions action to ensure security hardening.
- The Get the Flutter Version Environment action requires that the
pubspec.yaml
file contains anenvironment:flutter:
key, which is used for installing Flutter with the correct version.
Also known as CI, Continuous Integration runs Flutter static and dynamic tests on every pull request to main
and release/v*
, then the coverage report is stored as an artifact for reference. A comment is added to the pull request on every run as seen here, #10 (comment). Modify the workflow to further process the code coverage file using code quality or code review actions.
.github/workflows/cdelivery.yml
Also known as CDelivery (not to be mistaken with another CD, i.e., Continuous Deployment), Continuous Delivery drafts a pre-release on every push to main
and release/v*
. This ensures that the drafted release is created or updated. Manually remove the pre-release mark after it has been deployed and released to the app store.
.github/workflows/pull_request-opened.yml
To draft the release this workflow uses the Release Drafter action to compile the pull requests and categorizes it using the PR Labeler action. Add the .github/release-drafter.yml
and .github/pr-labeler.yml
files in your project since these are required configurations for these actions, respectively. Customize the configuration files as needed.
.github/workflows/deployment.yml
Deployment is triggered when the release draft (or any release) is published. It reruns the same Flutter static and dynamic tests from the CI before running Flutter's build commands. The app version used is based on the release tag, not the name. Lastly, build artifacts are uploaded as release assets.
The scripts and documentation in this project are released under the MIT License