-
-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add install script #22
Conversation
*) target="Linux_i386" ;; | ||
esac | ||
|
||
version=${1} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Optionally a git release tag can be provided to the script. Otherwise the latest release is used.
install.sh
Outdated
version="$(curl -s https://api.github.com/repos/thegreenwebfoundation/grid-intensity-go/releases/latest | grep tag_name | cut -d '"' -f 4)" | ||
fi | ||
|
||
version="$(echo $version | cut -d 'v' -f 2)" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a bit of a pain because the filenames don't have the v prefix.
e.g. grid-intensity_0.1.0_Darwin_arm64.tar.gz
"Darwin x86_64") target="Darwin_x86_64" ;; | ||
"Darwin arm64") target="Darwin_arm64" ;; | ||
"Linux aarch64") target="Linux_arm64" ;; | ||
*) target="Linux_i386" ;; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested this on Linux via Docker with aarch64
. So I think this is all the cases we need to cover.
I haven't attempted Windows support. I think we should create a separate script if we need that. Maybe with powershell we could also try chocately to have an alternative to homebrew. WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, let's make a separate issue for windows support - I think once we have this implemented for mainly POSIX based systems, it's easier to ask for the same, but for windows boxen 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi Ross, this looks good enough to merge in from my POV.
There's one thing about linting the script to catch a few common errors with shell scripting worth looking into, but otherwise
fi | ||
|
||
version="$(echo $version | cut -d 'v' -f 2)" | ||
grid_intensity_uri="https://github.com/thegreenwebfoundation/grid-intensity-go/releases/download/v${version}/grid-intensity_${version}_${target}.tar.gz" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This mostly looks good to me. For shellscripts, it's worth running content through https://www.shellcheck.net to catch any common linting errors. Here's the output I got when running this file through it.
[Line 19:](javascript:setPosition(19, 17))
version="$(echo $version | cut -d 'v' -f 2)"
^-- [SC2086](https://www.shellcheck.net/wiki/SC2086) (info): Double quote to prevent globbing and word splitting.
Did you mean: ([apply this](javascript:applyFixIndex([0])), apply [all SC2086](javascript:applyFixCode(2086)))
version="$(echo "$version" | cut -d 'v' -f 2)"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @mrchrisadams great idea to run it through the linter and that's fixed now.
Towards #12
The script can be curled like below. The sudo is needed because the binary is installed to
/usr/local/bin
.Shell scripting is not my strong suit 😅 so all feedback gratefully received!