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
|
- 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).
|
This is inspired by [`actions/setup-go`](https://github.com/actions/setup-go).
|
||||||
|
|
||||||
@@ -35,7 +35,7 @@ steps:
|
|||||||
uses: subosito/flutter-action@v2
|
uses: subosito/flutter-action@v2
|
||||||
with:
|
with:
|
||||||
channel: stable
|
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
|
- run: flutter --version
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ inputs:
|
|||||||
required: false
|
required: false
|
||||||
default: ""
|
default: ""
|
||||||
flutter-version-file:
|
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
|
required: false
|
||||||
default: ""
|
default: ""
|
||||||
architecture:
|
architecture:
|
||||||
@@ -91,7 +91,7 @@ runs:
|
|||||||
# It's not preinstalled on Windows runners.
|
# It's not preinstalled on Windows runners.
|
||||||
# See https://github.com/actions/runner-images/issues/7443#issuecomment-1514597691
|
# See https://github.com/actions/runner-images/issues/7443#issuecomment-1514597691
|
||||||
- name: Make yq tool available on Windows runners
|
- 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
|
run: choco install yq
|
||||||
shell: bash
|
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" ;;
|
n) VERSION="$OPTARG" ;;
|
||||||
f)
|
f)
|
||||||
VERSION_FILE="$OPTARG"
|
VERSION_FILE="$OPTARG"
|
||||||
if [ -n "$VERSION_FILE" ] && ! check_command yq; then
|
if [ -n "$VERSION_FILE" ]; then
|
||||||
echo "yq not found. Install it from https://mikefarah.gitbook.io/yq"
|
if [[ "$VERSION_FILE" != *".fvmrc" ]] && [[ "$VERSION_FILE" != *"fvm_config.json" ]] && ! check_command yq; then
|
||||||
exit 1
|
echo "yq not found. Install it from https://mikefarah.gitbook.io/yq"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
g) GIT_SOURCE="$OPTARG" ;;
|
g) GIT_SOURCE="$OPTARG" ;;
|
||||||
@@ -110,11 +112,24 @@ if [ -n "$VERSION_FILE" ]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
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
|
fi
|
||||||
|
|
||||||
ARR_CHANNEL=("${@:$OPTIND:1}")
|
ARR_CHANNEL=("${@:$OPTIND:1}")
|
||||||
CHANNEL="${ARR_CHANNEL[0]:-}"
|
if [ -z "${CHANNEL:-}" ]; then
|
||||||
|
CHANNEL="${ARR_CHANNEL[0]:-}"
|
||||||
|
fi
|
||||||
|
|
||||||
[ -z "$CHANNEL" ] && CHANNEL=stable
|
[ -z "$CHANNEL" ] && CHANNEL=stable
|
||||||
[ -z "$VERSION" ] && VERSION=any
|
[ -z "$VERSION" ] && VERSION=any
|
||||||
|
|||||||
Reference in New Issue
Block a user