Skip to content

Instantly share code, notes, and snippets.

@Aareon
Last active March 3, 2021 11:50
Show Gist options
  • Save Aareon/e06360d29119528e410bcfb1ab43a858 to your computer and use it in GitHub Desktop.
Save Aareon/e06360d29119528e410bcfb1ab43a858 to your computer and use it in GitHub Desktop.
golang and github cli
#!/bin/bash
## each separate version number must be less than 3 digit wide !
function version { echo "$@" | gawk -F. '{ printf("%03d%03d%03d\n", $1,$2,$3); }'; }
if ! command -v gh &> /dev/null
then
# install github cli
echo "github cli (gh) not installed"
ver="$(go version)"
ver="${ver:13:4}"
if [ "$(version "$ver")" -ge "$(version "1.14")" ]
then
echo "go min(1.14) version found $ver"
else
echo "needed go min(1.14) but found $ver"
exit
fi
echo "Cloning gh-cli"
cd
git clone --depth 1 https://github.com/cli/cli gh-cli
cd gh-cli
echo "Building gh-cli"
make
mv bin/gh $HOME/bin
cd
echo "Done"
else
echo "github cli (gh) is installed"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment