Skip to content

Commit 3aea9c1

Browse files
committed
Fallback to find release based on channel & dart_sdk_arch if hash lookup failed
1 parent 8c23974 commit 3aea9c1

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

action.sh

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,29 @@ if [[ $FLUTTER_VERSION == "latest" ]]; then
3131

3232
# Determine the latest Flutter SDK version
3333
if [ -f "$FLUTTER_RELEASE_MANIFEST_FILE" ]; then
34-
__FLUTTER_CURRENT_RELEASE=$(jq -r ".current_release.${FLUTTER_CHANNEL}" "$FLUTTER_RELEASE_MANIFEST_FILE")
35-
__QUERY="select(.hash == \"${__FLUTTER_CURRENT_RELEASE}\" and .dart_sdk_arch == \"${FLUTTER_ARCH}\")"
34+
__HASH=$(jq -r ".current_release.${FLUTTER_CHANNEL}" "$FLUTTER_RELEASE_MANIFEST_FILE")
35+
__QUERY="select(.hash == \"${__HASH}\" and .dart_sdk_arch == \"${FLUTTER_ARCH}\")"
36+
37+
# Find the version with matching architecture
3638
FLUTTER_VERSION=$(jq -r ".releases | map(${__QUERY}) | .[0].version" "$FLUTTER_RELEASE_MANIFEST_FILE")
3739
if [ -z "$FLUTTER_VERSION" ] || [ "$FLUTTER_VERSION" == "null" ]; then
38-
echo -e "::error::Failed to determine the latest Flutter SDK version."
39-
exit 1
40+
41+
# This is the last ditch effort to find a matching version
42+
# Some architectures may not have a matching version in the current release
43+
# I guess well-played Flutter team, well-played...
44+
45+
echo "::warning::No matching version found for architecture \"${FLUTTER_ARCH}\". Trying to find the last version with matching architecture..."
46+
__QUERY="select(.channel \"${FLUTTER_CHANNEL}\" and .dart_sdk_arch == \"${FLUTTER_ARCH}\")"
47+
FLUTTER_VERSION=$(jq -r ".releases | map(${__QUERY}) | .[0].version" "$FLUTTER_RELEASE_MANIFEST_FILE")
48+
49+
if [ -z "$FLUTTER_VERSION" ] || [ "$FLUTTER_VERSION" == "null" ]; then
50+
echo -e "::error::Failed to determine the latest Flutter SDK version."
51+
exit 1
52+
fi
4053
fi
4154
echo "Found the latest Flutter SDK version: ${FLUTTER_VERSION}"
4255
else
43-
echo -e "::error::Failed to determine the latest Flutter SDK version."
56+
echo -e "::error::Failed to parse Flutter SDK release manifest."
4457
exit 1
4558
fi
4659
fi

0 commit comments

Comments
 (0)