From 1a449444c387b1966244ae4d4f8c696479add0b2 Mon Sep 17 00:00:00 2001 From: Peter Leibiger Date: Wed, 25 Mar 2026 11:24:42 +0100 Subject: [PATCH] Simplify extraction of zip files (#379) * Simplify extraction of zip files in setup.sh Refactor unzip command to directly extract to target directory. By keeping the /flutter directory from inside the archive, we avoid having to use a temp directory and move afterwards. * fix: checkout specific version on main/master --- setup.sh | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/setup.sh b/setup.sh index 0a01308..b3c0b7b 100755 --- a/setup.sh +++ b/setup.sh @@ -51,18 +51,10 @@ download_archive() { case "$archive_name" in *.zip) - EXTRACT_PATH="$RUNNER_TEMP/_unzip_temp" - unzip -q -o "$archive_local" -d "$EXTRACT_PATH" - # Remove the folder again so that the move command can do a simple rename - # instead of moving the content into the target folder. - # This is a little bit of a hack since the "mv --no-target-directory" - # linux option is not available here - rm -r "$2" - mv "$EXTRACT_PATH"/flutter "$2" - rm -r "$EXTRACT_PATH" + unzip -q -o "$archive_local" -d "$2" ;; *) - tar xf "$archive_local" -C "$2" --strip-components=1 + tar xf "$archive_local" -C "$2" ;; esac @@ -230,12 +222,12 @@ if [ "$PRINT_ONLY" = true ]; then exit 0 fi -if [ ! -x "$CACHE_PATH/bin/flutter" ]; then +if [ ! -x "$CACHE_PATH/flutter/bin/flutter" ]; then if [ "$CHANNEL" = "master" ] || [ "$CHANNEL" = "main" ]; then - git clone -b "$CHANNEL" "$GIT_SOURCE" "$CACHE_PATH" + git clone -b "$CHANNEL" "$GIT_SOURCE" "$CACHE_PATH/flutter" if [ "$VERSION" != "any" ]; then - git config --global --add safe.directory "$CACHE_PATH" - (cd "$CACHE_PATH" && git checkout "$VERSION") + git config --global --add safe.directory "$CACHE_PATH/flutter" + (cd "$CACHE_PATH/flutter" && git checkout "$VERSION") fi else archive_url=$(echo "$VERSION_MANIFEST" | jq -r '.archive') @@ -244,12 +236,12 @@ if [ ! -x "$CACHE_PATH/bin/flutter" ]; then fi { - echo "FLUTTER_ROOT=$CACHE_PATH" + echo "FLUTTER_ROOT=$CACHE_PATH/flutter" echo "PUB_CACHE=$PUB_CACHE" } >>"${GITHUB_ENV:-/dev/null}" { - echo "$CACHE_PATH/bin" - echo "$CACHE_PATH/bin/cache/dart-sdk/bin" + echo "$CACHE_PATH/flutter/bin" + echo "$CACHE_PATH/flutter/bin/cache/dart-sdk/bin" echo "$PUB_CACHE/bin" } >>"${GITHUB_PATH:-/dev/null}"