feat: fvm support (#383)
* feat: added support for .fvmrc files, so it can fetch the flutter version from there * feat: changed README description of action to accomodate new changes
This commit is contained in:
@@ -23,7 +23,7 @@ steps:
|
||||
- run: flutter --version
|
||||
```
|
||||
|
||||
### Use version from pubspec.yaml
|
||||
### Use version from pubspec.yaml or FVM config
|
||||
|
||||
This is inspired by [`actions/setup-go`](https://github.com/actions/setup-go).
|
||||
|
||||
@@ -35,7 +35,7 @@ steps:
|
||||
uses: subosito/flutter-action@v2
|
||||
with:
|
||||
channel: stable
|
||||
flutter-version-file: pubspec.yaml # path to pubspec.yaml
|
||||
flutter-version-file: pubspec.yaml # path to pubspec.yaml or .fvmrc or .fvm/fvm_config.json
|
||||
- run: flutter --version
|
||||
```
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ inputs:
|
||||
required: false
|
||||
default: ""
|
||||
flutter-version-file:
|
||||
description: The pubspec.yaml file with exact Flutter version defined
|
||||
description: The pubspec.yaml or FVM config file with exact Flutter version defined
|
||||
required: false
|
||||
default: ""
|
||||
architecture:
|
||||
@@ -91,7 +91,7 @@ runs:
|
||||
# It's not preinstalled on Windows runners.
|
||||
# See https://github.com/actions/runner-images/issues/7443#issuecomment-1514597691
|
||||
- name: Make yq tool available on Windows runners
|
||||
if: runner.os == 'Windows' && inputs.flutter-version-file != ''
|
||||
if: runner.os == 'Windows' && inputs.flutter-version-file != '' && !endsWith(inputs.flutter-version-file, '.fvmrc') && !endsWith(inputs.flutter-version-file, 'fvm_config.json')
|
||||
run: choco install yq
|
||||
shell: bash
|
||||
|
||||
|
||||
25
setup.sh
25
setup.sh
@@ -92,9 +92,11 @@ while getopts 'tc:k:d:l:pa:n:f:g:' flag; do
|
||||
n) VERSION="$OPTARG" ;;
|
||||
f)
|
||||
VERSION_FILE="$OPTARG"
|
||||
if [ -n "$VERSION_FILE" ] && ! check_command yq; then
|
||||
echo "yq not found. Install it from https://mikefarah.gitbook.io/yq"
|
||||
exit 1
|
||||
if [ -n "$VERSION_FILE" ]; then
|
||||
if [[ "$VERSION_FILE" != *".fvmrc" ]] && [[ "$VERSION_FILE" != *"fvm_config.json" ]] && ! check_command yq; then
|
||||
echo "yq not found. Install it from https://mikefarah.gitbook.io/yq"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
g) GIT_SOURCE="$OPTARG" ;;
|
||||
@@ -110,11 +112,24 @@ if [ -n "$VERSION_FILE" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
VERSION="$(yq eval '.environment.flutter' "$VERSION_FILE")"
|
||||
if [[ "$VERSION_FILE" == *".fvmrc" ]]; then
|
||||
VERSION="$(jq -r '.flutter' "$VERSION_FILE")"
|
||||
elif [[ "$VERSION_FILE" == *"fvm_config.json" ]]; then
|
||||
VERSION="$(jq -r '.flutterSdkVersion // .flutter' "$VERSION_FILE")"
|
||||
else
|
||||
VERSION="$(yq eval '.environment.flutter' "$VERSION_FILE")"
|
||||
fi
|
||||
|
||||
if [[ "$VERSION" == "stable" ]] || [[ "$VERSION" == "beta" ]] || [[ "$VERSION" == "master" ]] || [[ "$VERSION" == "main" ]]; then
|
||||
CHANNEL="$VERSION"
|
||||
VERSION="any"
|
||||
fi
|
||||
fi
|
||||
|
||||
ARR_CHANNEL=("${@:$OPTIND:1}")
|
||||
CHANNEL="${ARR_CHANNEL[0]:-}"
|
||||
if [ -z "${CHANNEL:-}" ]; then
|
||||
CHANNEL="${ARR_CHANNEL[0]:-}"
|
||||
fi
|
||||
|
||||
[ -z "$CHANNEL" ] && CHANNEL=stable
|
||||
[ -z "$VERSION" ] && VERSION=any
|
||||
|
||||
Reference in New Issue
Block a user