Skip to content

Commit e19f775

Browse files
authored
Updates and fixes to CD (#4)
1 parent 7e2a971 commit e19f775

File tree

4 files changed

+40
-20
lines changed

4 files changed

+40
-20
lines changed

.github/README.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,28 @@ Create a workflow `.yml` file in your `.github/workflows` directory. Example wor
1010

1111
All workflows use the [Ensure SHA Pinned Actions](https://github.com/marketplace/actions/ensure-sha-pinned-actions) action to ensure security hardening.
1212

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.
14+
1315
### Continuous Integration
1416
[![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)
1517

1618
[`.github/workflows/ci.yml`](workflows/ci.yml)
1719

18-
Also known as CI, Continuous Integration runs Flutter static and dynamic tests, 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.
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.
21+
22+
### Continuous Delivery
23+
[![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)
24+
25+
[`.github/workflows/cdelivery.yml`](workflows/cdelivery.yml)
26+
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.
28+
29+
### Deployment
30+
[![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)
31+
32+
[`.github/workflows/deployment.yml`](workflows/deployment.yml)
1933

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

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

.github/release-drafter.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ categories:
66
labels:
77
- 'bug'
88
- 'security'
9-
change-template: ' $TITLE — #$NUMBER'
9+
change-template: '* $TITLE — #$NUMBER'
1010
template: $CHANGES

.github/workflows/cdelivery.yml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,8 @@ jobs:
7474
# unit testing
7575
- name: Run Flutter ${{ matrix.category }} tests
7676
if: matrix.category != 'static'
77-
run: flutter test --no-pub --coverage --coverage-path=./coverage/lcov.${{ matrix.category }}.info test/${{ matrix.category }}s
77+
run: flutter test --no-pub test/${{ matrix.category }}s
7878
working-directory: code
79-
- name: Upload code coverage to GitHub
80-
if: matrix.category != 'static'
81-
uses: actions/upload-artifact@726a6dcd0199f578459862705eed35cda05af50b # v2.2.1
82-
with:
83-
name: code-coverage
84-
path: code/coverage/lcov.${{ matrix.category }}.info
8579

8680
draft_release:
8781
name: Draft a release
@@ -93,5 +87,7 @@ jobs:
9387
- name: Draft the release
9488
id: release-drafter
9589
uses: release-drafter/release-drafter@3782ccd1a495040818a9e5d0e8bc4ed22d3b1361 # v5.12.1
90+
with:
91+
prerelease: true
9692
env:
9793
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/deployment.yml

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@ jobs:
2020
runs-on: ubuntu-latest
2121
steps:
2222
- name: The release should not have any existing assets
23-
run: echo "${{ toJson(github.event.release.assets) }}"
23+
if: join(github.event.release.assets, '') != ''
24+
run: |
25+
echo "::error::The "${{ github.event.release.name }}" release has preexisting assets. This workflow will not be able to upload build files as release assets."
26+
exit 1
2427
2528
testing:
2629
name: Run ${{ matrix.category }} testing
@@ -83,14 +86,8 @@ jobs:
8386
# unit testing
8487
- name: Run Flutter ${{ matrix.category }} tests
8588
if: matrix.category != 'static'
86-
run: flutter test --no-pub --coverage --coverage-path=./coverage/lcov.${{ matrix.category }}.info test/${{ matrix.category }}s
89+
run: flutter test --no-pub test/${{ matrix.category }}s
8790
working-directory: code
88-
- name: Upload code coverage to GitHub
89-
if: matrix.category != 'static'
90-
uses: actions/upload-artifact@726a6dcd0199f578459862705eed35cda05af50b # v2.2.1
91-
with:
92-
name: code-coverage
93-
path: code/coverage/lcov.${{ matrix.category }}.info
9491

9592
build:
9693
name: Build the ${{ matrix.file }} file
@@ -157,22 +154,35 @@ jobs:
157154
run: flutter pub get
158155
working-directory: code
159156

157+
# all
158+
- name: Set the app version
159+
uses: microsoft/variable-substitution@6287962da9e5b6e68778dc51e840caa03ca84495 # v1
160+
with:
161+
files: 'code/pubspec.ya?ml'
162+
env:
163+
version: ${{ github.event.release.tag_name }}
164+
160165
# apk
161166
- name: Build an Android APK file
162167
if: matrix.file == 'apk'
163-
run: flutter build apk --obfuscate --split-debug-info=build/app/outputs/symbols
168+
run: |
169+
cat pubspec.yaml
170+
flutter build apk --obfuscate --split-debug-info=build/app/outputs/symbols
164171
working-directory: code
165172

166173
# aab
167174
- name: Build an Android App Bundle file
168175
if: matrix.file == 'aab'
169-
run: flutter build appbundle --obfuscate --split-debug-info=build/app/outputs/symbols
176+
run: |
177+
cat pubspec.yaml
178+
flutter build appbundle --obfuscate --split-debug-info=build/app/outputs/symbols
170179
working-directory: code
171180

172181
# ipa
173182
- name: Build an iOS App Store Package file
174183
if: matrix.file == 'ipa'
175184
run: |
185+
cat pubspec.yaml
176186
flutter build ios --no-codesign --obfuscate --split-debug-info=build/app/outputs/symbols
177187
echo "::warning::TODO: fastlane export_ipa"
178188
working-directory: code

0 commit comments

Comments
 (0)