Skip to content

Commit

Permalink
ci: CI/CD Pipeline feature (#134)
Browse files Browse the repository at this point in the history
## Description

- Add build and deployment workflow with Github action
- builds and deploy the android app **on push** to the development
branch
- deploy to Github Releases
- deploy to Firebase App Distributions

## Type of Change

<!--- Put an `x` in all the boxes that apply: -->

- [x] ✨ New feature (non-breaking change which adds functionality)
- [ ] 🛠️ Bug fix (non-breaking change which fixes an issue)
- [ ] ❌ Breaking change (fix or feature that would cause existing
functionality to change)
- [ ] 🧹 Code refactor
- [x] ✅ Build configuration change
- [ ] 📝 Documentation
- [ ] 🗑️ Chore


## Pre-launch Checklist

- [ ] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [ ] I read and ran all relevant commands as specififed in the Running
Tests section of the [Contributor Guide].
- [ ] The title of the PR follows the [Conventional Commits] guideline
- [ ] My local branch follows the naming standards in the [Deepsource
Branch Naming Convention] or [Biodiversity Branch Naming Convention]
- [ ] I listed at least one issue that this PR fixes in the description
above.
- [ ] I updated `pubspec.yaml` with an appropriate new version according
to the [pub versioning philosophy],
- [ ] I updated/added relevant documentation (doc comments with `///`).
- [ ] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [ ] All existing and new tests are passing.


[Contributor Guide]:
https://github.com/FlutterPlaza/.github/blob/main/CONTRIBUTING.md
[Conventional Commits]:
https://www.conventionalcommits.org/en/v1.0.0-beta.4/
[pub versioning philosophy]: https://dart.dev/tools/pub/versioning
[Biodiversity Branch Naming Convention]: https://bit.ly/3DyYSwM
[Deepsource Branch Naming Convention]: https://bit.ly/3Y08Gs4
  • Loading branch information
jeffrey0606 authored Mar 22, 2023
2 parents 3dbbdb2 + 4aef6b9 commit 55e35ea
Show file tree
Hide file tree
Showing 5 changed files with 409 additions and 182 deletions.
106 changes: 106 additions & 0 deletions .github/workflows/android-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
name: Android App Release for development branch

on:
push:
branches:
- development

jobs:
version:
name: Create version number # using GitVersion
runs-on: ubuntu-latest #macos-latest
steps:
- uses: actions/checkout@v3
- name: Fetch all history for all tags and branches
run: git fetch --prune --depth=10000
- name: Install GitVersion
uses: gittools/actions/gitversion/[email protected]
with:
versionSpec: '5.x'
- name: Use GitVersion
id: gitversion
uses: gittools/actions/gitversion/[email protected]
- name: Create android-version.txt with nuGetVersion
run: echo ${{ steps.gitversion.outputs.nuGetVersion }} > android-version.txt
- name: Upload android-version.txt
uses: actions/upload-artifact@v3
with:
name: gitversion
path: android-version.txt
build:
name: Build Appbundle and Apks
needs: [ version ]
runs-on: ubuntu-latest #macos-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
java-version: '12.x'
distribution: 'zulu'
cache: 'gradle'
- uses: subosito/flutter-action@v2
with:
flutter-version: '3.3.7'
cache: true
channel: 'stable'
- run: flutter upgrade
- run: flutter --version
- name: Get DEV_GOOGLE_SERVICES_JSON content write it into app/src/development/google-services.json
env:
DEV_GOOGLE_SERVICES_JSON: ${{ secrets.DEV_GOOGLE_SERVICES_JSON }}
run: echo "$DEV_GOOGLE_SERVICES_JSON" > android/app/src/development/google-services.json
- run: flutter pub get
# - run: flutter test
- run: flutter build apk --profile --flavor development --target lib/main_development.dart
# - run: flutter build appbundle
- name: upload app builds files
uses: actions/upload-artifact@v3
with:
name: flutter-app-builds
path: |
build/app/outputs/flutter-apk/app-development-profile.apk
github-deploy:
name: Deploy Build to Github
needs: [ build, version ]
runs-on: ubuntu-latest #macos-latest
steps:
- name: Get android-version.txt
uses: actions/download-artifact@v3
with:
name: gitversion
- name: Read version
id: version
uses: juliangruber/read-file-action@v1
with:
path: android-version.txt
- name: Get app builds
uses: actions/download-artifact@v3
with:
name: flutter-app-builds
- name: Echo android-version.txt
run: echo "${{ steps.version.outputs.content }}"
- name: Display structure of downloaded files
run: ls -R
- name: Create a Release in GitHub
uses: ncipollo/release-action@v1
with:
artifacts: "flutter-apk/app-development-profile.apk"
token: ${{ secrets.GH_TOKEN }}
tag: ${{ steps.version.outputs.content }}
commit: ${{ github.sha }}
firebase-deploy:
name: Deploy Build to Firebase App Distribution
needs: [ build ]
runs-on: ubuntu-latest #macos-latest
steps:
- name: Get app builds
uses: actions/download-artifact@v3
with:
name: flutter-app-builds
- name: upload artifact to Firebase App Distribution
uses: wzieba/Firebase-Distribution-Github-Action@v1
with:
appId: ${{secrets.FIREBASE_ANDROID_APP_ID}}
serviceCredentialsFileContent: ${{ secrets.CREDENTIAL_FILE_CONTENT }}
groups: testers
file: flutter-apk/app-development-profile.apk
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
buildscript {
ext.kotlin_version = '1.6.10'
ext.kotlin_version = '1.6.10'//1.8.10 -> 1.8.10 because of release build failures
repositories {
google()
mavenCentral()
Expand Down
112 changes: 48 additions & 64 deletions lib/injection.config.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 55e35ea

Please sign in to comment.