Skip to content

Commit

Permalink
Added install.sh and Readme
Browse files Browse the repository at this point in the history
  • Loading branch information
hamza72x committed Feb 20, 2023
1 parent f2a9b52 commit 7f9c2d6
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,20 @@

- the more dependencies a formula has, the more faster it will (compared to brew)

## Requirements

- [brew.sh](https://brew.sh/)

## Install

```sh
# build from source
go install github.com/hamza72x/brewc@latest

# or use the install script
curl -sL https://raw.githubusercontent.com/hamza72x/brewc/master/install.sh | sh

# or check the releases page
```

## Usage
Expand Down
77 changes: 77 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#/bin/bash

# This script will install the latest version of the `brewc` into /usr/local/bin

# Check if the user has curl, jq, cut installed
green='\033[0;32m'
end='\033[0m'

echo -e "${green}Checking if curl, jq, cut are installed...${end}"

if ! command -v curl &> /dev/null
then
echo "curl could not be found"
exit
fi

if ! command -v jq &> /dev/null
then
echo "jq could not be found"
exit
fi

if ! command -v cut &> /dev/null
then
echo "cut could not be found"
exit
fi

# lowercase uname output
arch=$(uname -m | tr '[:upper:]' '[:lower:]')
goos=$(uname -s | tr '[:upper:]' '[:lower:]')

if [ "$arch" = "x86_64" ]; then
arch="amd64"
fi

latest_tag=$(curl -sL https://api.github.com/repos/hamza72x/brewc/tags | jq -r '.[0].name' | cut -d 'v' -f 2)
url=https://github.com/hamza72x/brewc/releases/download/v$latest_tag/brewc_$latest_tag\_$goos\_$arch.tar.gz

echo -e "${green}Detected OS: $goos${end}"
echo -e "${green}Detected Arch: $arch${end}"

echo ""

echo -e "${green}Latest version: $latest_tag${end}"
echo -e "${green}Download URL: $url${end}"
echo -e "${green}Installing brewc into /usr/local/bin${end}"


echo ""

# now ask if everything looks good and want to continue
read -p "Looks good? Continue? [y/N] " -n 1 -r

# quit if the user doesn't want to continue
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
echo
echo "Aborting..."
exit 1
fi

# download the latest version
curl -L $url | tar -xz -C /usr/local/bin

# print usage
echo ""
echo -e "${green}Verifying installation...${end}"
echo ""

if command -v brewc &> /dev/null
then
brewc --help
else
echo "brewc could not be found, make sure /usr/local/bin is in your PATH, or try /usr/local/bin/brewc --help"
exit
fi

0 comments on commit 7f9c2d6

Please sign in to comment.