Skip to content

Commit

Permalink
chore: improve install script
Browse files Browse the repository at this point in the history
  • Loading branch information
beliven-fabrizio-gortani committed Dec 29, 2024
1 parent bd8ad49 commit 2ba103b
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions install.sh
Original file line number Diff line number Diff line change
@@ -1,26 +1,30 @@
#!/bin/sh

trap _cleanup EXIT

_cleanup() {
rm -rf /tmp/archive.zip
rm -rf /tmp/archive
}

key_to_link="zipball_url"
vendor="beliven-it"
repository_name="laravel-sync"
repository="$vendor/$repository_name"
archive_name="archive"

archive_path_folder="/tmp/$archive_name"
archive_path_zip="$archive_path_folder.zip"

trap _cleanup EXIT

_cleanup() {
rm -rf $archive_path_zip
rm -rf $archive_path_folder
}

latest_release=$(curl -s https://api.github.com/repos/$repository/releases/latest | grep "$key_to_link" | cut -d '"' -f 4)

if [ -n "$latest_release" ]; then
echo "Latest release: $latest_release"
echo "Download the latest release of $repository ..."

curl -sL "$latest_release" -o /tmp/archive.zip
unzip -q -j /tmp/archive.zip -d /tmp/archive
cp -r /tmp/archive/$repository_name .
curl -sL "$latest_release" -o $archive_path_zip
unzip -q -j $archive_path_zip -d $archive_path_folder
cp -r $archive_path_folder/$repository_name .
chmod +x $repository_name
echo "Done!"
else
Expand Down

0 comments on commit 2ba103b

Please sign in to comment.