Optimize Your CI/CD Pipeline
Get instant insights into your CI/CD performance and costs. Reduce build times by up to 45% and save on infrastructure costs.
steps:
- name: Set up Flutter
uses: subosito/flutter-action@v2
with:
channel: stable
flutter-version: 3.19.0
- run: flutter --version
flutter-action
Flutter environment for use in GitHub Actions. It works on Linux, Windows, and macOS.
We found this amazing GitHub Action setup for Flutter development supporting Linux, Windows, macOS. It's called "flutter-action" and allows for pinning Flutter versions and respective setup of builds for multiple platforms and caching. We believed it may be helpful to optimally configure CI/CD pipelines of Flutter apps.
Precisely define the Flutter version in your pubspec.yaml file so that the version can be used directly from the file. Also, be reminded that on Windows, the file will have to manually install yq since it is not pre-installed.
This action easily integrates with actions/cache to make builds run even faster with cached dependencies. It also makes it easy to customize the cache keys and paths to support more parameters such as OS, channel, version, etc.
How to Build Flutter for iOS for Using flutter-action?
jobs:
main:
runs-on: macos-latest
steps:
- name: Clone repository
uses: actions/checkout@v4
- name: Set up Flutter
uses: subosito/flutter-action@v2
with:
channel: stable
- run: flutter pub get
- run: flutter test
- run: flutter build ios --release --no-codesign
actions/checkout@v4
: Checks out your repository.subosito/flutter-action@v2
: Sets up the specified Flutter environment.- The commands that follow install dependencies, run tests, and build the iOS app without code signing.
How to Build for the Web with GitHub Actions
steps:
- name: Clone repository
uses: actions/checkout@v4
- name: Set up Flutter
uses: subosito/flutter-action@v2
with:
channel: stable
- run: flutter pub get
- run: flutter test
- run: flutter build web
- This setup is quite similar to iOS but tailored for web applications, focusing on web-specific build commands.
How to Build Flutter for Windows Desktop Using GitHub Actions?
jobs:
main:
runs-on: windows-latest
steps:
- name: Clone repository
uses: actions/checkout@v4
- name: Set up Flutter
uses: subosito/flutter-action@v2
with:
channel: stable
- run: flutter build windows
- Specifically targets the Windows platform, ensuring compatibility with Windows-specific dependencies and environments.
How to Build for Linux Desktop with flutter-action?
jobs:
main:
runs-on: ubuntu-latest
steps:
- name: Clone repository
uses: actions/checkout@v4
- name: Set up Flutter
uses: subosito/flutter-action@v2
with:
channel: stable
- run: |
sudo apt-get update -y
sudo apt-get install -y ninja-build libgtk-3-dev
- run: flutter build linux
- Includes steps for setting up necessary libraries on a Linux environment before building the application.
How to Build for macOS Desktop Using GitHub Actions
jobs:
main:
runs-on: macos-latest
steps:
- name: Clone repository
uses: actions/checkout@v4
- name: Set up Flutter
uses: subosito/flutter-action@v2
with:
channel: stable
- run: flutter build macos
- The setup mirrors iOS, adjusted for macOS specifics in the build command.
These configurations are designed to be dropped into your CI/CD workflows to manage the build process across various platforms effectively, ensuring your Flutter applications are built correctly for each target environment.