9/24/2016 - 4:52 PM

Bash | Install an executable file (tar.gz) from a Github repository

Bash | Install an executable file (tar.gz) from a Github repository

# This script will allow you to create an installation script, which will download a release from a GitHub repository,
# and install it on /usr/local/bin, accessible by user's PATH. The release file should include an executable, without any
# subfolders. After tweaking this file, you may now add it to your
# repository at your root as `` in the master branch. Users may run this script with:
#  curl -s<user>/<repo>/master/ | sh

# Custom configuration

github_release_filename="<your release filename>.tar.gz"
github_repo="<repository name>"
executable_name="<your executable file inside your compressed package>"

# -----------------------

# Fixed variables.

# Download the compressed file.
echo "Downloading $github_user/$github_repo $github_release_version_tag from $download_url ..."
curl -L -o $tmp_file $download_url

# Extract its content.
echo "Extracting executable into $executable_target_folder ..."
sudo tar -xvzf $tmp_file -C $executable_target_folder >> /dev/null

# Add executable permissions.
echo "Adding executable permissions to $executable_path ..."
sudo chmod +x $executable_path

# After install content (run help or man).
echo "Done! $github_user/$github_repo is now installed."
printf "\n\n"
$executable_name --help