Skip to content

Commit 3a0b6ea

Browse files
committed
Draft verify Flutter SDK archive with sha256 checksum
1 parent 8388133 commit 3a0b6ea

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

action.sh

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ then
1919
then
2020
CURRENT_RELEASE=$(jq -r ".current_release.${FLUTTER_CHANNEL}" "$FLUTTER_RELEASE_MANIFEST_FILE")
2121
FLUTTER_VERSION=$(jq -r ".releases | map(select(.hash == \"${CURRENT_RELEASE}\")) | .[0].version" "$FLUTTER_RELEASE_MANIFEST_FILE")
22+
FLUTTER_SHA256=$(jq -r ".releases | map(select(.hash == \"${CURRENT_RELEASE}\")) | .[0].sha256" "$FLUTTER_RELEASE_MANIFEST_FILE")
2223
rm "$FLUTTER_RELEASE_MANIFEST_FILE"
2324
else
2425
echo -e "::error::Failed to detect the latest version."
@@ -82,7 +83,18 @@ if [ ! -d "${FLUTTER_RUNNER_TOOL_CACHE}" ]; then
8283

8384
# Download installation archive
8485
DOWNLOAD_PATH="${RUNNER_TEMP}/${FLUTTER_BUILD}"
85-
curl --connect-timeout 15 --retry 5 "$FLUTTER_DOWNLOAD_URL" > ${DOWNLOAD_PATH}
86+
if curl --connect-timeout 15 --retry 5 "$FLUTTER_DOWNLOAD_URL" > ${DOWNLOAD_PATH};
87+
then
88+
if [[ $OS == "linux" ]]
89+
then
90+
echo "${FLUTTER_SHA256} ${DOWNLOAD_PATH}" | sha256sum -c -
91+
else
92+
echo "${FLUTTER_SHA256} ${DOWNLOAD_PATH}" | shasum -a 256 -c -
93+
fi
94+
else
95+
echo -e "::error::Download failed! Please check passed arguments."
96+
exit 1
97+
fi
8698

8799
# Prepare tool cache folder
88100
mkdir -p "${FLUTTER_RUNNER_TOOL_CACHE}"

0 commit comments

Comments
 (0)