Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatically get Flutter version from pubspec.yaml #282

Closed
bartekpacia opened this issue Mar 24, 2024 · 2 comments · Fixed by #290
Closed

Automatically get Flutter version from pubspec.yaml #282

bartekpacia opened this issue Mar 24, 2024 · 2 comments · Fixed by #290

Comments

@bartekpacia
Copy link
Collaborator

bartekpacia commented Mar 24, 2024

Use case

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

@yurikoles
Copy link

And the principal difference between this issue and #211 with #215 is?

@bartekpacia
Copy link
Collaborator Author

bartekpacia commented Mar 25, 2024

The differences:

  • This is an issue, not a discussion, thus it gets a bit more visibility. If @subosito agrees I am happy to implement this feature.
  • This issue proposes to use flutter-version-file instead of trying to do so implicitly
  • This issue proposes for this action to only accept simple semver versions (like "3.19.4"), and not deal with version ranges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants