mirror of
https://github.com/subosito/flutter-action.git
synced 2026-07-14 08:42:41 +02:00
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
This commit is contained in:
26
setup.sh
26
setup.sh
@@ -51,18 +51,10 @@ download_archive() {
|
|||||||
|
|
||||||
case "$archive_name" in
|
case "$archive_name" in
|
||||||
*.zip)
|
*.zip)
|
||||||
EXTRACT_PATH="$RUNNER_TEMP/_unzip_temp"
|
unzip -q -o "$archive_local" -d "$2"
|
||||||
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"
|
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
tar xf "$archive_local" -C "$2" --strip-components=1
|
tar xf "$archive_local" -C "$2"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
@@ -230,12 +222,12 @@ if [ "$PRINT_ONLY" = true ]; then
|
|||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -x "$CACHE_PATH/bin/flutter" ]; then
|
if [ ! -x "$CACHE_PATH/flutter/bin/flutter" ]; then
|
||||||
if [ "$CHANNEL" = "master" ] || [ "$CHANNEL" = "main" ]; 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
|
if [ "$VERSION" != "any" ]; then
|
||||||
git config --global --add safe.directory "$CACHE_PATH"
|
git config --global --add safe.directory "$CACHE_PATH/flutter"
|
||||||
(cd "$CACHE_PATH" && git checkout "$VERSION")
|
(cd "$CACHE_PATH/flutter" && git checkout "$VERSION")
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
archive_url=$(echo "$VERSION_MANIFEST" | jq -r '.archive')
|
archive_url=$(echo "$VERSION_MANIFEST" | jq -r '.archive')
|
||||||
@@ -244,12 +236,12 @@ if [ ! -x "$CACHE_PATH/bin/flutter" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
{
|
{
|
||||||
echo "FLUTTER_ROOT=$CACHE_PATH"
|
echo "FLUTTER_ROOT=$CACHE_PATH/flutter"
|
||||||
echo "PUB_CACHE=$PUB_CACHE"
|
echo "PUB_CACHE=$PUB_CACHE"
|
||||||
} >>"${GITHUB_ENV:-/dev/null}"
|
} >>"${GITHUB_ENV:-/dev/null}"
|
||||||
|
|
||||||
{
|
{
|
||||||
echo "$CACHE_PATH/bin"
|
echo "$CACHE_PATH/flutter/bin"
|
||||||
echo "$CACHE_PATH/bin/cache/dart-sdk/bin"
|
echo "$CACHE_PATH/flutter/bin/cache/dart-sdk/bin"
|
||||||
echo "$PUB_CACHE/bin"
|
echo "$PUB_CACHE/bin"
|
||||||
} >>"${GITHUB_PATH:-/dev/null}"
|
} >>"${GITHUB_PATH:-/dev/null}"
|
||||||
|
|||||||
Reference in New Issue
Block a user