Skip to content
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

Merged
merged 2 commits into from
Jun 22, 2022
Merged

Conversation

rossf7
Copy link
Contributor

@rossf7 rossf7 commented Jun 21, 2022

Towards #12

The script can be curled like below. The sudo is needed because the binary is installed to /usr/local/bin.

curl -fsSL https://raw.githubusercontent.com/rossf7/grid-intensity-go/install-script/install.sh | sudo sh

Shell scripting is not my strong suit 😅 so all feedback gratefully received!

*) target="Linux_i386" ;;
esac

version=${1}
Copy link
Contributor Author

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)"
Copy link
Contributor Author

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" ;;
Copy link
Contributor Author

@rossf7 rossf7 Jun 21, 2022

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?

Copy link
Member

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 👍

@rossf7 rossf7 requested a review from mrchrisadams June 21, 2022 17:34
Copy link
Member

@mrchrisadams mrchrisadams left a 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 :shipit:

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"
Copy link
Member

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)"

Copy link
Contributor Author

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.

@rossf7 rossf7 merged commit e260ae3 into thegreenwebfoundation:main Jun 22, 2022
@rossf7 rossf7 deleted the install-script branch June 22, 2022 08:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants