|
1 | 1 | # GitHub Actions: Flutter Workflows
|
2 | 2 |
|
3 |
| -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](https://github.com/flutter/gallery) repository. |
| 3 | +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](https://github.com/flutter/gallery) repository. Continue reading to apply these to your Flutter project. |
| 4 | + |
| 5 | +## Disclaimer |
| 6 | +This is still in active development, and it currently supports iOS and Android deployments only. Please open a pull request to support other platforms. |
4 | 7 |
|
5 | 8 | ## Usage
|
6 | 9 |
|
7 |
| -Create a workflow `.yml` file in your `.github/workflows` directory. Example workflows are available in this repository. For more information, reference the GitHub Help Documentation for [Creating a workflow file](https://help.github.com/en/articles/configuring-a-workflow#creating-a-workflow-file). |
| 10 | +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](https://help.github.com/en/articles/configuring-a-workflow#creating-a-workflow-file). |
| 11 | + |
| 12 | +*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](https://guides.github.com/introduction/flow/) and [release based workflow](https://lab.github.com/githubtraining/create-a-release-based-workflow). |
8 | 13 |
|
9 |
| -## Workflows |
| 14 | +### Protected Branches |
| 15 | +Recommended rules for the `main` and `release/v*` branches: |
| 16 | +- [x] Require status checks to pass before merging |
| 17 | + - [x] Require branches to be up to date before merging |
| 18 | + - [x] Check security hardening |
| 19 | + - [x] Generate coverage report |
| 20 | + - [x] Run static testing |
| 21 | + - [x] Run unit testing |
| 22 | + - [x] Run widget testing |
10 | 23 |
|
11 |
| -All workflows use the [Ensure SHA Pinned Actions](https://github.com/marketplace/actions/ensure-sha-pinned-actions) action to ensure security hardening. |
| 24 | +### Workflows |
12 | 25 |
|
13 |
| -_Note:_ The [Get the Flutter Version Environment](https://github.com/marketplace/actions/get-the-flutter-version-environment) action requires that the [`pubspec.yaml`](pubspec.yaml) file contains an `environment:flutter:` key. This is used for installing Flutter in the workflows. |
| 26 | +- All of the workflows here use the [Ensure SHA Pinned Actions](https://github.com/marketplace/actions/ensure-sha-pinned-actions) action to ensure security hardening. |
| 27 | +- The [Get the Flutter Version Environment](https://github.com/marketplace/actions/get-the-flutter-version-environment) action requires that the [`pubspec.yaml`](pubspec.yaml) file contains an `environment:flutter:` key, which is used for installing Flutter with the correct version. |
14 | 28 |
|
15 |
| -### Continuous Integration |
| 29 | +#### Continuous Integration |
16 | 30 | [](https://github.com/zgosalvez/github-actions-flutter-workflow/actions?query=workflow%3ACI)
|
17 | 31 |
|
18 | 32 | [`.github/workflows/ci.yml`](workflows/ci.yml)
|
19 | 33 |
|
20 |
| -Also known as CI, Continuous Integration runs Flutter static and dynamic tests on every pull request to `main`, then the coverage report is stored as an artifact for reference. Modify the workflow to further process the code coverage file using [code quality](https://github.com/marketplace?type=actions) or [code review](https://github.com/marketplace?category=code-review&type=actions) actions. |
| 34 | +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)](https://github.com/zgosalvez/github-actions-flutter-workflows/pull/10#issuecomment-753592566). Modify the workflow to further process the code coverage file using [code quality](https://github.com/marketplace?type=actions) or [code review](https://github.com/marketplace?category=code-review&type=actions) actions. |
21 | 35 |
|
22 |
| -### Continuous Delivery |
| 36 | +#### Continuous Delivery |
23 | 37 | [](https://github.com/zgosalvez/github-actions-flutter-workflow/actions?query=workflow%3ACDelivery)
|
24 | 38 |
|
25 | 39 | [`.github/workflows/cdelivery.yml`](workflows/cdelivery.yml)
|
26 | 40 |
|
27 |
| -Also known as CDelivery (not to be mistaken with another CD, Continuous Deployment), Continuous Delivery reruns the same Flutter static and dynamic tests from the CI on every push to `main`, then a pre-release draft is created. Manually, remove the pre-release mark after it has been deployed and released to the app store. |
| 41 | +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. |
| 42 | + |
| 43 | +[`.github/workflows/pull_request-opened.yml`](workflows/pull_request-opened.yml) |
| 44 | + |
| 45 | +To draft the release this workflow uses the [Release Drafter](https://github.com/marketplace/actions/release-drafter) action to compile the pull requests and categorizes it using the [PR Labeler](https://github.com/marketplace/actions/pr-labeler) action. Add the [`.github/release-drafter.yml`](release-drafter.yml) and [`.github/pr-labeler.yml`](pr-labeler.yml) files in your project since these are required configurations for these actions, respectively. Customize the configuration files as needed. |
28 | 46 |
|
29 |
| -### Deployment |
| 47 | +#### Deployment |
30 | 48 | [](https://github.com/zgosalvez/github-actions-flutter-workflow/actions?query=workflow%3ADeployment)
|
31 | 49 |
|
32 | 50 | [`.github/workflows/deployment.yml`](workflows/deployment.yml)
|
33 | 51 |
|
34 |
| -Deployment is triggered when the release draft 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. |
| 52 | +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. |
35 | 53 |
|
36 | 54 | ## License
|
37 | 55 | The scripts and documentation in this project are released under the [MIT License](LICENSE)
|
0 commit comments