Skip to content

Commit 92bb897

Browse files
authored
Release v1.0.0+14 (#12)
* Fixes release notes with GitHub flow (#10) * Adds PR actions (#11) * Adds Protected Branches * Adds PR actions * Update README.md * Update README.md (#13) * Optimize CD (#14)
1 parent e5e622e commit 92bb897

File tree

7 files changed

+73
-78
lines changed

7 files changed

+73
-78
lines changed

.github/CODEOWNERS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# https://help.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners
2+
3+
* @zgosalvez

.github/CONTRIBUTING.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Contributing
2+
3+
## Welcome
4+
Thank you for contributing to this repository! :bow:
5+
6+
## Process
7+
1. Create a branch with the following [supported](pr-labeler.yml) prefixes:
8+
- `feature/` (i.e., enhancements)
9+
- `hotfix/` (i.e., bug fixes)
10+
2. Make changes
11+
3. Create a PR to the appropriate branch (`release/v*`/`main`)

.github/README.md

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,55 @@
11
# GitHub Actions: Flutter Workflows
22

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.
47

58
## Usage
69

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).
813

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
1023

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
1225

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.
1428

15-
### Continuous Integration
29+
#### Continuous Integration
1630
[![CI](https://github.com/zgosalvez/github-actions-flutter-workflow/workflows/CI/badge.svg)](https://github.com/zgosalvez/github-actions-flutter-workflow/actions?query=workflow%3ACI)
1731

1832
[`.github/workflows/ci.yml`](workflows/ci.yml)
1933

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.
2135

22-
### Continuous Delivery
36+
#### Continuous Delivery
2337
[![CDelivery](https://github.com/zgosalvez/github-actions-flutter-workflow/workflows/CDelivery/badge.svg)](https://github.com/zgosalvez/github-actions-flutter-workflow/actions?query=workflow%3ACDelivery)
2438

2539
[`.github/workflows/cdelivery.yml`](workflows/cdelivery.yml)
2640

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.
2846

29-
### Deployment
47+
#### Deployment
3048
[![Deployment](https://github.com/zgosalvez/github-actions-flutter-workflow/workflows/Deployment/badge.svg)](https://github.com/zgosalvez/github-actions-flutter-workflow/actions?query=workflow%3ADeployment)
3149

3250
[`.github/workflows/deployment.yml`](workflows/deployment.yml)
3351

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.
3553

3654
## License
3755
The scripts and documentation in this project are released under the [MIT License](LICENSE)

.github/pr-labeler.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
enhancement: feature/*
2+
bug: hotfix/*

.github/workflows/cdelivery.yml

Lines changed: 4 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ name: CDelivery
22

33
on:
44
push:
5-
branches: [ main ]
5+
branches:
6+
- main
7+
- release/v*
68

79
jobs:
810
security_hardening:
@@ -14,73 +16,9 @@ jobs:
1416
- name: Ensure SHA pinned actions
1517
uses: zgosalvez/github-actions-ensure-sha-pinned-actions@e70e07ef05f0a3bf1483fde3c50eeab9c1805041 # v1.0.1
1618

17-
testing:
18-
name: Run ${{ matrix.category }} testing
19-
needs: security_hardening
20-
runs-on: ubuntu-latest
21-
strategy:
22-
matrix:
23-
category: [static, unit, widget]
24-
fail-fast: false
25-
steps:
26-
- name: Clone the repository
27-
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4
28-
with:
29-
path: code
30-
- name: Get Flutter version
31-
id: get-flutter-version
32-
uses: zgosalvez/github-actions-get-flutter-version-env@2106839043b63948638cf22ee33718862fdcc57d # v1.1.2
33-
with:
34-
pubspec-file-path: code/pubspec.yaml
35-
- name: Cache Flutter
36-
id: flutter-cache
37-
uses: actions/cache@0781355a23dac32fd3bac414512f4b903437991a # v2.1.3
38-
with:
39-
path: flutter
40-
key: ${{ env.cache-name }}-ubuntu-latest-${{ steps.get-flutter-version.outputs.version }}-${{ hashFiles('code/pubspec.lock') }}
41-
restore-keys: |
42-
${{ env.cache-name }}-ubuntu-latest-${{ steps.get-flutter-version.outputs.version }}-
43-
${{ env.cache-name }}-ubuntu-latest-
44-
${{ env.cache-name }}-
45-
env:
46-
cache-name: flutter-cache
47-
- name: Clone the Flutter repository
48-
if: steps.flutter-cache.outputs.cache-hit != 'true'
49-
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4
50-
with:
51-
repository: flutter/flutter
52-
ref: ${{ steps.get-flutter-version.outputs.version }}
53-
path: flutter
54-
- name: Add the flutter tool to the path
55-
run: |
56-
echo "$GITHUB_WORKSPACE/flutter/bin" >> $GITHUB_PATH
57-
echo "$GITHUB_WORKSPACE/flutter/bin/cache/dart-sdk/bin" >> $GITHUB_PATH
58-
- name: Populate the Flutter tool's cache of binary artifacts
59-
if: steps.flutter-cache.outputs.cache-hit != 'true'
60-
run: |
61-
flutter config --no-analytics
62-
flutter precache
63-
- name: Get Flutter packages
64-
run: flutter pub get
65-
working-directory: code
66-
67-
# static testing
68-
- name: Analyze Flutter
69-
if: matrix.category == 'static'
70-
uses: zgosalvez/github-actions-analyze-flutter@f5a4e9edfc655081eb438cf5901f1d48c9e5d281 # v1.3.2
71-
with:
72-
fail-on-warnings: true
73-
working-directory: code
74-
75-
# unit testing
76-
- name: Run Flutter ${{ matrix.category }} tests
77-
if: matrix.category != 'static'
78-
run: flutter test --no-pub test/${{ matrix.category }}s
79-
working-directory: code
80-
8119
draft_release:
8220
name: Draft a release
83-
needs: testing
21+
needs: security_hardening
8422
runs-on: ubuntu-latest
8523
steps:
8624
- name: Clone the repository

.github/workflows/ci.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ name: CI
22

33
on:
44
pull_request:
5-
branches: [ main ]
5+
branches:
6+
- main
7+
- release/v*
68

79
jobs:
810
security_hardening:
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Pull Request (Opened)
2+
3+
on:
4+
pull_request:
5+
types: [opened]
6+
7+
jobs:
8+
assign_author:
9+
name: Assign Author to the Pull Request
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Assign Author to the Pull Request
13+
uses: technote-space/assign-author@6252488282b99652aef47451a353eb88aea24666 # v1.5.7
14+
15+
pr-labeler:
16+
name: Label the PR based on the branch
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: TimonVS/pr-labeler-action@bd0b592a410983316a454e3d48444608f028ec8e # v3.1.0
20+
env:
21+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)