This GitHub Action (written in composite run steps) allows you to leverage GitHub Actions to get the Flutter environment version from the pubspec file. This is primarily used before using the Flutter action.
Create a workflow .yml
file in your .github/workflows
directory. An example workflow is available below. For more information, reference the GitHub Help Documentation for Creating a workflow file.
For more information on this input, see the Workflow syntax for GitHub Actions
pubspec-file-path
: The pubspec.yaml file path. Optional. Default:pubspec.yaml
For more information on this output, see the Workflow syntax for GitHub Actions and the Context and expression syntax for GitHub Actions
version
: The Flutter version
- Your
pubspec.yaml
file must contain the Flutter version under theenvironment:flutter:
key. For example:
environment:
flutter: 1.22.4
- Use the action's output as an input to Flutter action. For example:
on: push
name: Sample Workflow
jobs:
build:
name: Example
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Get Flutter version
id: get-flutter-version
uses: zgosalvez/github-actions-get-flutter-version-env@v2
- name: Set up Flutter
uses: subosito/flutter-action@v1
with:
flutter-version: ${{ steps.get-flutter-version.outputs.version }}
A special mention goes to @daohoangson, who came up with the initial solution at subosito/flutter-action/issues/47#issuecomment-675821988.
This is used in my opinionated GitHub Actions: Flutter Workflows repository along with other actions for a complete end-to-end DevOps experience.
The scripts and documentation in this project are released under the MIT License