Skip to content

Commit 83e201c

Browse files
committed
Optimize runner tool cache output
1 parent d733e70 commit 83e201c

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

action.sh

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ FLUTTER_OS=$(echo "${OS}" | awk '{print tolower($0)}')
99
FLUTTER_ARCH=$(echo "${ARCH}" | awk '{print tolower($0)}')
1010
FLUTTER_RELEASE_URL=${FLUTTER_RELEASE_URL:-"https://storage.googleapis.com/flutter_infra_release/releases"}
1111

12+
# WARNING:
13+
# Setting the Flutter SDK version to "latest" will automatically determine the latest Flutter SDK version via the release manifest.
14+
# But it will break the caching mechanism, and the action will download the Flutter SDK on every run.
15+
1216
# Automatically determine the latest Flutter SDK version via the release manifest
1317
if [[ $FLUTTER_VERSION == "latest" ]]; then
1418
# Flutter SDK release manifest
@@ -76,13 +80,11 @@ fi
7680
# /stable /windows/ flutter_windows_3.0.2-stable.zip
7781
# /beta /windows/ flutter_windows_3.1.0-9.0.pre-beta.zip
7882
FLUTTER_BUILD_ARTIFACT_ID="flutter_${FLUTTER_BUILD_OS}_${FLUTTER_VERSION}-${FLUTTER_CHANNEL}.${EXT}"
79-
FLUTTER_BUILD_ARTIFACT_URL=${FLUTTER_BUILD_ARTIFACT_URL:-"${FLUTTER_RELEASE_URL}/${FLUTTER_CHANNEL}/${FLUTTER_OS}/${FLUTTER_BUILD_ARTIFACT_ID}"}
83+
FLUTTER_BUILD_ARTIFACT_URL="${FLUTTER_RELEASE_URL}/${FLUTTER_CHANNEL}/${FLUTTER_OS}/${FLUTTER_BUILD_ARTIFACT_ID}"
8084

8185
# Flutter runner tool cache and pub cache
82-
# Ref: https://github.com/flutter-actions/setup-flutter/pull/11
83-
# FLUTTER_RUNNER_TOOL_CACHE=${{ runner.tool_cache }}/flutter-${{ runner.os }}-${{ inputs.version }}-${{ runner.arch }}-${{ inputs.channel }}
84-
# FLUTTER_PUB_CACHE=${{ runner.temp }}/pub-cache
85-
FLUTTER_RUNNER_TOOL_CACHE="${RUNNER_TOOL_CACHE}/flutter/${FLUTTER_BUILD_ARTIFACT_ID}"
86+
# Thanks to @alijvhr for providing a fix, https://github.com/flutter-actions/setup-flutter/pull/11
87+
FLUTTER_RUNNER_TOOL_CACHE="${RUNNER_TOOL_CACHE}/flutter/${FLUTTER_VERSION}/${FLUTTER_CHANNEL}"
8688
FLUTTER_PUB_CACHE="${RUNNER_TEMP}/flutter/pub-cache"
8789

8890
# Check if Flutter SDK already exists, otherwise download and install
@@ -118,7 +120,7 @@ if [ ! -d "${FLUTTER_RUNNER_TOOL_CACHE}" ]; then
118120
exit 1
119121
fi
120122
else
121-
echo "Cache restored Flutter SDK version: ${FLUTTER_VERSION} (${FLUTTER_CHANNEL}) on \"${FLUTTER_OS}_${ARCH}\""
123+
echo "Flutter SDK version restored from cache: ${FLUTTER_VERSION} (${FLUTTER_CHANNEL}) on \"${FLUTTER_OS}_${ARCH}\""
122124
fi
123125

124126
# Configure pub to use a fixed location.

0 commit comments

Comments
 (0)