Skip to content

Commit

Permalink
feat: update install script
Browse files Browse the repository at this point in the history
  • Loading branch information
amazingandyyy committed Apr 18, 2022
1 parent 7c42609 commit 38487b7
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 17 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# gofuzzyclone

go fuzzy search repos in regex and clone
Go fuzzy search repos with regex or wildcard

# Installation

Expand Down
Binary file modified bin/gofuzzyclone
Binary file not shown.
4 changes: 2 additions & 2 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import (
"strings"
"time"

"gofuzzyclone/lib/helper"
"gofuzzyclone/lib/logger"
"gofuzzyclone/internal/helper"
"gofuzzyclone/internal/logger"

"github.com/briandowns/spinner"
"github.com/go-git/go-git/v5"
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ require (
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.25.0 // indirect
gopkg.in/warnings.v0 v0.1.2 // indirect
)
)
2 changes: 1 addition & 1 deletion lib/helper/helper.go → internal/helper/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package helper

import (
"fmt"
"gofuzzyclone/lib/logger"
"gofuzzyclone/internal/logger"
)

// HandleError is a helper function to handle error
Expand Down
File renamed without changes.
35 changes: 23 additions & 12 deletions scripts/install.sh
Original file line number Diff line number Diff line change
@@ -1,23 +1,34 @@
#!/usr/bin/env bash
export stable_version=0.0.6

export package_name=gofuzzyclone
export author=amazingandyyy
[[ -n "$1" ]] && stable_version=$1
# get the latest version or change to a specific version
export latest_version=$(curl --silent "https://api.github.com/repos/$author/$package_name/releases/latest" | grep '"tag_name"' | sed -E 's/.*"([^"]+)".*/\1/')
[[ -n "$1" ]] && latest_version=$1

echo "> installing $package_name@$stable_version"
curl -LsO https://github.com/$author/$package_name/archive/refs/tags/$stable_version.zip &&
unzip -o $stable_version.zip &&
rm -rf /opt/homebrew/bin/$package_name &&
sudo touch /opt/homebrew/bin/$package_name &&
chmod +x $package_name-$stable_version/bin/$package_name &&
mv -f $package_name-$stable_version/bin/$package_name /opt/homebrew/bin
rm -rf $package_name-$stable_version $stable_version.zip
echo "Installing/upgrading to $package_name@$latest_version (latest)"

fmpfolder=/tmp
tmpoupoutput=$fmpfolder/$package_name-$latest_version
tmpoupoutputgz=$tmpoupoutput.tar.gz
userlocalbin=/usr/local/bin/$package_name

curl -Ls "https://github.com/$author/$package_name/archive/refs/tags/$latest_version.tar.gz" -o $tmpoupoutputgz
tar -zxf $tmpoupoutputgz --directory /tmp
if ! ls -d $userlocalbin > /dev/null 2>&1
then
sudo touch $userlocalbin
sudo mv $fmpfolder/$package_name-$latest_version/bin/$package_name $userlocalbin
else
sudo mv $fmpfolder/$package_name-$latest_version/bin/$package_name $userlocalbin
fi

rm -rf $fmpfolder/$package_name $tmpoupoutput $tmpoupoutputgz

if ! [[ -x $(command -v $package_name) ]]; then
echo "$package_name failed to install" >&2
echo "Installed $package_name unsuccessfully" >&2
exit 1
else
echo "Installed $package_name@$stable_version successfully!"
echo "Installed $package_name@$latest_version successfully!"
gofuzzyclone -help
fi

0 comments on commit 38487b7

Please sign in to comment.