Created
February 16, 2022 17:10
-
-
Save aadipoddar/6f36f2214fd3c43eaf16755e5ff96543 to your computer and use it in GitHub Desktop.
This is a complete Workflow file for Flutter apps. It supports build and release for all platforms.
This file contains hidden or 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 Test Analysis Build | |
on: | |
push: | |
branches: [master] | |
pull_request: | |
branches: [master] | |
jobs: | |
flutter_test: | |
name: Flutter Test and Analysis | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Setup Java | |
uses: actions/setup-java@v2 | |
with: | |
distribution: 'zulu' | |
java-version: '11' | |
- name: Setup Flutter | |
uses: subosito/flutter-action@v2 | |
with: | |
channel: "stable" | |
- name: Version | |
run: flutter --version | |
- name: Doctor | |
run: flutter doctor | |
- name: Pub Get | |
run: flutter pub get | |
- name: Analyze | |
run: flutter analyze | |
- name: Test | |
run: flutter test | |
build_ios: | |
name: Build Flutter (iOS) | |
needs: [flutter_test] | |
runs-on: macos-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Setup Flutter | |
uses: subosito/flutter-action@v2 | |
with: | |
channel: "stable" | |
- name: Build iOS | |
run: | | |
flutter build ios --no-codesign | |
cd build/ios/iphoneos | |
mkdir Payload | |
cd Payload | |
ln -s ../Runner.app | |
cd .. | |
zip -r app.ipa Payload | |
- name: Publish Artifacts | |
uses: actions/upload-artifact@v2 | |
with: | |
name: assets-for-download | |
path: build/ios/iphoneos/app.ipa | |
build_android: | |
name: Build Flutter (Android) | |
needs: [flutter_test] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Setup Java | |
uses: actions/setup-java@v2 | |
with: | |
distribution: 'zulu' | |
java-version: '11' | |
- name: Setup Flutter | |
uses: subosito/flutter-action@v2 | |
with: | |
channel: "stable" | |
- name: Build App Bundle | |
run: flutter build appbundle | |
- name: Build Apk | |
run: flutter build apk --release | |
- name: Publish Artifacts | |
uses: actions/upload-artifact@v2 | |
with: | |
name: assets-for-download | |
path: | | |
build/app/outputs/bundle/release/app-release.aab | |
build/app/outputs/flutter-apk/app-release.apk | |
build_web: | |
name: Build Flutter (Web) | |
needs: [flutter_test] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Setup Flutter | |
uses: subosito/flutter-action@v2 | |
with: | |
channel: "stable" | |
- name: Build web | |
run: flutter build web --release | |
- name: Zip | |
run: | | |
cd build | |
zip -r web.zip web | |
- name: Upload web artifact | |
uses: actions/upload-artifact@v1 | |
with: | |
name: assets-for-download | |
path: build/web.zip | |
build_windows: | |
name: Build Flutter (Windows) | |
needs: [flutter_test] | |
runs-on: windows-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Setup Flutter | |
uses: subosito/flutter-action@v2 | |
with: | |
channel: "stable" | |
- name: Config Windows | |
run: flutter config --enable-windows-desktop | |
- name: Build Windows | |
run: flutter build windows | |
- name: Zip | |
run: | | |
cd build/windows/runner/Release | |
7z a -r ../Release * | |
cd.. | |
- name: Publish Artifacts | |
uses: actions/upload-artifact@v2 | |
with: | |
name: assets-for-download | |
path: build/windows/runner/Release.7z | |
build_linux: | |
name: Build Flutter (Linux) | |
needs: [flutter_test] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Setup Flutter | |
uses: subosito/flutter-action@v2 | |
with: | |
channel: "stable" | |
- name: Install Dependencies | |
run: | | |
sudo apt-get update -y | |
sudo apt-get install -y ninja-build libgtk-3-dev | |
- name: Config Linux | |
run: flutter config --enable-linux-desktop | |
- name: Build Linux | |
run: flutter build linux --release | |
- name: Zip | |
run: | | |
cd build/linux/x64/release | |
zip -r linux.zip bundle | |
- name: Upload web artifact | |
uses: actions/upload-artifact@v1 | |
with: | |
name: assets-for-download | |
path: build/linux/x64/release/linux.zip | |
build_macos: | |
name: Build Flutter (Macos) | |
needs: [flutter_test] | |
runs-on: macos-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Setup Flutter | |
uses: subosito/flutter-action@v2 | |
with: | |
channel: "stable" | |
- name: Config Macos | |
run: flutter config --enable-macos-desktop | |
- name: Build Macos | |
run: flutter build macos --release | |
- name: Zip | |
run: | | |
cd build/macos/Build/Products | |
zip -r macos.zip Release | |
- name: Publish Artifacts | |
uses: actions/upload-artifact@v2 | |
with: | |
name: assets-for-download | |
path: build/macos/Build/Products/macos.zip | |
publish_release: | |
name: Publish Build files to releases | |
needs: [flutter_test, build_macos, build_linux, build_windows, build_web, build_android, build_ios] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Downlaod Artifacts | |
uses: actions/download-artifact@v2 | |
with: | |
name: assets-for-download | |
- name: Push Files to Releases | |
uses: ncipollo/release-action@v1 | |
with: | |
artifacts: "app.ipa, flutter-apk/app-release.apk, bundle/release/app-release.aab, linux.zip, macos.zip, Release.7z, web.zip" | |
tag: v1.${{ github.run_number }} | |
token: ${{ secrets.TOKEN }} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment