Skip to content

Composite GitHub Action to setup and cache the Flutter SDK.

License

Notifications You must be signed in to change notification settings

hrishikesh-kadam/setup-flutter

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

setup-flutter

CI

Composite GitHub Action to setup and cache the Flutter SDK.

Caching Flutter will help to save some minutes.
Private repositories with Free plan has only 2,000 automation minutes/month.
And the minutes are counted as -
Linux - 1 minute counted as 1 regular minute.
Windows - 1 minute counted as 2 regular minutes.
macOS - 1 minute counted as 10 regular minutes.
Usage for the month can be seen in https://github.com/settings/billing

Below are the stats of before and after caching based on the following conditions -

  1. Time is the lowest recorded time of the 'Setup Flutter' step, from
    the multiple runs of ci-compare.yml workflow.
  2. Ran on the same SHA of the Action.
  3. Ran on the same ref(SHA) of the Flutter SDK.
Step OS Time
Setup Flutter (Before caching) ubuntu-latest 44s
windows-latest 74s
macos-latest 60s
Setup Flutter (After caching) ubuntu-latest 10s
windows-latest 24s
macos-latest 15s

Please Note

  • Flutter is installed via GitHub repository source and not via https://storage.googleapis.com source.
    The later source comes with Installation Bundles.
    See also, Flutter's Official Installation.
  • GitHub will remove any cache entries that have not been accessed in over 7 days.
  • This action is intended for the GitHub-hosted runners.
    Not tested on the Self-hosted runners yet.

Usage

Basic

steps:
  - uses: actions/checkout@v4
  - name: Setup Flutter
    uses: hrishikesh-kadam/setup-flutter@v1
  - run: # Run your flutter or dart command here

ref

description channel (stable, beta or master), version(3.7.8) or any git reference(3.9.0-0.1.pre).
required false
default 'stable'
steps:
  - uses: actions/checkout@v4
  - name: Setup Flutter
    uses: hrishikesh-kadam/setup-flutter@v1
    with:
      ref: beta # or 3.7.8 or 3.9.0-0.1.pre

installationPath

description Installation Path of Flutter SDK.
required false
default '${{ runner.tool_cache }}/flutter'
steps:
  - uses: actions/checkout@v4
  - name: Setup Flutter
    uses: hrishikesh-kadam/setup-flutter@v1
    with:
      installationPath: '${{ runner.tool_cache }}/flutter-foo'

actionsCache

description Cache Flutter SDK for subsequent GitHub Actions Workflow.
required false
default 'true'
steps:
  - uses: actions/checkout@v4
  - name: Setup Flutter
    uses: hrishikesh-kadam/setup-flutter@v1
    with:
      actionsCache: 'false'

actionsCacheKey

description An explicit key for a cache entry.
SHA of ref's HEAD will be appended to the given key.
Default key will be computed as `flutter-{OS}-{ref}-{ref_head}`.
required false
default ''
steps:
  - uses: actions/checkout@v4
  - name: Setup Flutter
    uses: hrishikesh-kadam/setup-flutter@v1
    with:
      actionsCacheKey: 'flutter-${{ runner.os }}'

setFlutterRootPath

description Set FLUTTER_ROOT to path where Flutter is installed.
required false
default 'false'
steps:
  - uses: actions/checkout@v4
  - name: Setup Flutter
    uses: hrishikesh-kadam/setup-flutter@v1
    with:
      setFlutterRootPath: 'true'

setPubCachePath

description Set PUB_CACHE to desired path, where pub saves dependencies.
required false
default ''
my-job:
  runs-on: ${{ matrix.runner }}
  strategy:
    matrix:
      runner: [ ubuntu-latest, macos-latest ]
      pubCachePath: [ '$HOME/.pub-cache' ]
      include:
        - runner: windows-latest
          pubCachePath: '$LOCALAPPDATA\Pub\Cache'
  steps:
    - uses: actions/checkout@v4
    - name: Setup Flutter
      uses: hrishikesh-kadam/setup-flutter@v1
      with:
        setPubCachePath: ${{ matrix.pubCachePath }}

addPubCacheBinToPath

description Add PUB_CACHE bin to PATH.
Note: On Windows, activated global packages can be run by without specifying dart pub global run only on pwsh, cmd and powershell.
required false
default 'false'
steps:
  - uses: actions/checkout@v4
  - name: Setup Flutter
    uses: hrishikesh-kadam/setup-flutter@v1
    with:
      addPubCacheBinToPath: 'true'
  - run: |
      dart pub global activate dhttpd
      dhttpd --help

flutterPrecache

description Populate the Flutter tool's cache of binary artifacts.
For additional download options, see flutter help precache.
required false
default 'false'
steps:
  - uses: actions/checkout@v4
  - name: Setup Flutter
    uses: hrishikesh-kadam/setup-flutter@v1
    with:
      flutterPrecache: 'true'
        # will execute `flutter precache`
      # flutterPrecache: '--linux --web'
        # will execute `flutter precache --linux --web`

About

Composite GitHub Action to setup and cache the Flutter SDK.

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published

Languages