I like to define my Flutter version like this in pubspec.yaml:
name: awesome_flutter_app
description: Some random cross-platform app.
version: 1.0.0+1
publish_to: none
environment:
sdk: ">=3.3.2 <4.0.0"
flutter: 3.19.4
dependencies:
# ...
This is useful and I really like it because it's very easy to retrieve the version with yq:
$ yq '.environment.flutter' pubspec.yaml
3.19.4
It avoids ambiguity and makes sure both developers and CI use the same Flutter version when building. Right now this is how I accomplish this in my workflows:
jobs:
main:
# ...
steps:
# ...
- name: Get Flutter version
id: get_flutter_version
run: |
brew install yq
echo "result=$(yq '.environment.flutter' pubspec.yaml)" >> $GITHUB_OUTPUT
- name: Set up Flutter
uses: subosito/flutter-action@v2
with:
channel: stable
flutter-version: ${{ steps.get_flutter_version.outputs.result }}
Proposal
It'd be great if we could do this instead:
jobs:
main:
# ...
steps:
# ...
- name: Set up Flutter
uses: subosito/flutter-action@v2
with:
channel: stable
flutter-version-file: pubspec.yaml # path to the pubspec.yaml file
Of course, it would only work if yq '.environment.flutter' pubspec.yaml returns a valid semver version, and not something like flutter: ">=3.19.4". People who prefer things the way they are currently would not have to do anything at all, and continue using this action without any breaking changes.
This would be shorter
Both ubuntu-* and macos-* GitHub runners come with yq already installed (just like they come with jq already installed), so this small additional dependency shouldn't be blocker.
More context
The feature I suggest here is already available in several official GitHub Actions, such as actions/setup-go@v5 and actions/setup-ruby@v1. I think it'd be great if this awesome action also supported it :-)
Use case
I like to define my Flutter version like this in
pubspec.yaml
:This is useful and I really like it because it's very easy to retrieve the version with
yq
:It avoids ambiguity and makes sure both developers and CI use the same Flutter version when building. Right now this is how I accomplish this in my workflows:
Proposal
It'd be great if we could do this instead:
Of course, it would only work if
yq '.environment.flutter' pubspec.yaml
returns a valid semver version, and not something likeflutter: ">=3.19.4"
. People who prefer things the way they are currently would not have to do anything at all, and continue using this action without any breaking changes.This would be shorter
Both
ubuntu-*
andmacos-*
GitHub runners come withyq
already installed (just like they come withjq
already installed), so this small additional dependency shouldn't be blocker.More context
The feature I suggest here is already available in several official GitHub Actions, such as
actions/setup-go@v5
andactions/setup-ruby@v1
. I think it'd be great if this awesome action also supported it :-)This feature was discussed in https://github.com/subosito/flutter-action/discussions/215, but in a slightly different (worse) form