Flutter Android CI/CD #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Flutter Android CI/CD | |
on: | |
push: | |
tags: | |
- 'v*' | |
workflow_dispatch: | |
jobs: | |
build-android: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Setup Java | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'zulu' | |
java-version: '17' | |
- name: Cache Flutter packages | |
uses: actions/cache@v2 | |
with: | |
path: | | |
~/.pub-cache | |
frontend/.dart_tool | |
core/.dart_tool | |
key: ${{ runner.os }}-pub-cache-${{ hashFiles('**/pubspec.yaml') }} | |
restore-keys: | | |
${{ runner.os }}-pub-cache- | |
- name: Setup Flutter | |
uses: subosito/flutter-action@v2 | |
with: | |
flutter-version: '3.24.2' | |
channel: 'stable' | |
- name: Get dependencies (frontend) | |
working-directory: ./frontend | |
run: flutter pub get | |
- name: Get dependencies (core) | |
working-directory: ./core | |
run: flutter pub get | |
- name: Run build_runner (frontend) | |
working-directory: ./frontend | |
run: flutter pub run build_runner build --delete-conflicting-outputs | |
- name: Run build_runner (core) | |
working-directory: ./core | |
run: flutter pub run build_runner build --delete-conflicting-outputs | |
- name: Build APK | |
working-directory: ./frontend | |
run: flutter build apk --release | |
- name: Upload APK | |
uses: actions/upload-artifact@v3 | |
with: | |
name: release-apk | |
path: frontend/build/app/outputs/flutter-apk/app-release.apk | |
- name: Create Release | |
if: startsWith(github.ref, 'refs/tags/') | |
uses: softprops/action-gh-release@v1 | |
with: | |
files: frontend/build/app/outputs/flutter-apk/app-release.apk | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |