File tree Expand file tree Collapse file tree 1 file changed +18
-3
lines changed
Expand file tree Collapse file tree 1 file changed +18
-3
lines changed Original file line number Diff line number Diff line change @@ -951,13 +951,28 @@ function fetch_and_deploy_gh_release() {
951951 }
952952
953953 mkdir -p " $target "
954- if [[ " $filename " == * .zip ]]; then
954+ if [[ " $filename " == * .zip ]]; then
955955 if ! command -v unzip & > /dev/null; then
956956 $STD apt-get install -y unzip
957957 fi
958- $STD unzip " $tmpdir /$filename " -d " $target "
958+
959+ local top_level_entries
960+ top_level_entries=$( unzip -l " $tmpdir /$filename " | awk ' {print $4}' | grep -v ' ^$' | cut -d/ -f1 | sort -u)
961+
962+ if [[ $( wc -l <<< " $top_level_entries" ) -eq 1 ]]; then
963+ unzip -q " $tmpdir /$filename " -d " $tmpdir /unzip"
964+ shopt -s dotglob nullglob
965+ cp -r " $tmpdir /unzip/" * " $target /"
966+ shopt -u dotglob nullglob
967+ else
968+ unzip -q " $tmpdir /$filename " -d " $target "
969+ fi
970+
959971 elif [[ " $filename " == * .tar.* ]]; then
960- if tar -tf " $tmpdir /$filename " | grep -qE ' ^([^/]+/){2}' ; then
972+ local top_level_entries
973+ top_level_entries=$( tar -tf " $tmpdir /$filename " | cut -d/ -f1 | sort -u)
974+
975+ if [[ $( wc -l <<< " $top_level_entries" ) -eq 1 ]]; then
961976 tar --strip-components=1 -xf " $tmpdir /$filename " -C " $target "
962977 else
963978 tar -xf " $tmpdir /$filename " -C " $target "
You can’t perform that action at this time.
0 commit comments