Skip to content

Updates and fixes to CD #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 31 commits into from
Dec 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions .github/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,28 @@ Create a workflow `.yml` file in your `.github/workflows` directory. Example wor

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

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

### Continuous Integration
[![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)

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

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

### Continuous Delivery
[![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)

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

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.

### Deployment
[![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)

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

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

## License
The scripts and documentation in this project are released under the [MIT License](LICENSE)
2 changes: 1 addition & 1 deletion .github/release-drafter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ categories:
labels:
- 'bug'
- 'security'
change-template: ' $TITLE — #$NUMBER'
change-template: '* $TITLE — #$NUMBER'
template: $CHANGES
10 changes: 3 additions & 7 deletions .github/workflows/cdelivery.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,8 @@ jobs:
# unit testing
- name: Run Flutter ${{ matrix.category }} tests
if: matrix.category != 'static'
run: flutter test --no-pub --coverage --coverage-path=./coverage/lcov.${{ matrix.category }}.info test/${{ matrix.category }}s
run: flutter test --no-pub test/${{ matrix.category }}s
working-directory: code
- name: Upload code coverage to GitHub
if: matrix.category != 'static'
uses: actions/upload-artifact@726a6dcd0199f578459862705eed35cda05af50b # v2.2.1
with:
name: code-coverage
path: code/coverage/lcov.${{ matrix.category }}.info

draft_release:
name: Draft a release
Expand All @@ -93,5 +87,7 @@ jobs:
- name: Draft the release
id: release-drafter
uses: release-drafter/release-drafter@3782ccd1a495040818a9e5d0e8bc4ed22d3b1361 # v5.12.1
with:
prerelease: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
30 changes: 20 additions & 10 deletions .github/workflows/deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: The release should not have any existing assets
run: echo "${{ toJson(github.event.release.assets) }}"
if: join(github.event.release.assets, '') != ''
run: |
echo "::error::The "${{ github.event.release.name }}" release has preexisting assets. This workflow will not be able to upload build files as release assets."
exit 1

testing:
name: Run ${{ matrix.category }} testing
Expand Down Expand Up @@ -83,14 +86,8 @@ jobs:
# unit testing
- name: Run Flutter ${{ matrix.category }} tests
if: matrix.category != 'static'
run: flutter test --no-pub --coverage --coverage-path=./coverage/lcov.${{ matrix.category }}.info test/${{ matrix.category }}s
run: flutter test --no-pub test/${{ matrix.category }}s
working-directory: code
- name: Upload code coverage to GitHub
if: matrix.category != 'static'
uses: actions/upload-artifact@726a6dcd0199f578459862705eed35cda05af50b # v2.2.1
with:
name: code-coverage
path: code/coverage/lcov.${{ matrix.category }}.info

build:
name: Build the ${{ matrix.file }} file
Expand Down Expand Up @@ -157,22 +154,35 @@ jobs:
run: flutter pub get
working-directory: code

# all
- name: Set the app version
uses: microsoft/variable-substitution@6287962da9e5b6e68778dc51e840caa03ca84495 # v1
with:
files: 'code/pubspec.ya?ml'
env:
version: ${{ github.event.release.tag_name }}

# apk
- name: Build an Android APK file
if: matrix.file == 'apk'
run: flutter build apk --obfuscate --split-debug-info=build/app/outputs/symbols
run: |
cat pubspec.yaml
flutter build apk --obfuscate --split-debug-info=build/app/outputs/symbols
working-directory: code

# aab
- name: Build an Android App Bundle file
if: matrix.file == 'aab'
run: flutter build appbundle --obfuscate --split-debug-info=build/app/outputs/symbols
run: |
cat pubspec.yaml
flutter build appbundle --obfuscate --split-debug-info=build/app/outputs/symbols
working-directory: code

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