-
Notifications
You must be signed in to change notification settings - Fork 0
FB-16931 Ruby 3.1 #7
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,5 @@ | ||
| #!/bin/bash | ||
|
|
||
| set -e | ||
| #!/usr/bin/env bash | ||
| set -eu | ||
|
|
||
| if [ -z "$USER" ]; then | ||
| echo "Aborting! No USER environment variable set" | ||
|
|
@@ -12,22 +11,48 @@ if [ "$(id -u)" = 0 ]; then | |
| exit 4 | ||
| fi | ||
|
|
||
| if ! command -v curl >/dev/null 2>&1; then | ||
| echo "Aborting! No curl found (install and retry)" | ||
| exit 5 | ||
| echo "Requesting sudo access to install packages if needed" | ||
| sudo date | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think |
||
|
|
||
| if ! [ -x "$(command -v curl)" ]; then | ||
| echo "Installing curl..." | ||
| sudo apt-get install -y curl | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is non-portable - does a base X Linux distribution not include curl? |
||
| fi | ||
|
|
||
| if ! command -v ruby >/dev/null || \ | ||
| (command -v ruby >/dev/null && ruby -e 'exit RUBY_VERSION.split(".").first(2).join(".").to_f < 2.3'); then | ||
| echo "No suitable Ruby found (installing vendor Ruby)" | ||
| eval "$(curl -fsSL https://raw.githubusercontent.com/Linuxbrew/install/master/install-ruby)" | ||
| if [ ! -f "$HOME/.ssh/id_rsa.pub" ]; then | ||
| echo "Ensure you have your GitHub SSH key at ~/.ssh/id_rsa.pub" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like (at least) GitHub recommend a
|
||
| exit 1 | ||
| fi | ||
|
|
||
| if [ -z "$GITHUB_TOKEN" ]; then | ||
| echo "Please provide your Github Token (you can generate one at https://github.com/settings/tokens):" | ||
| read -s GITHUB_TOKEN | ||
| echo "Checking for brew installation" | ||
| if ! [ -x "$(command -v brew)" ]; then | ||
| # https://docs.brew.sh/Homebrew-on-Linux | ||
| echo "Installing brew..." | ||
| sudo apt-get install -y build-essential procps file git | ||
| /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" | ||
| # Allow brew to be used in this script | ||
| eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)" | ||
| fi | ||
|
|
||
| echo "Checking for rbenv installation" | ||
| if ! [ -x "$(command -v rbenv)" ]; then | ||
| echo "Installing rbenv" | ||
| brew install rbenv | ||
| fi | ||
|
|
||
| if [ ! -f "$HOME/.rbenv/shims/ruby" ]; then | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Presumably we can ask |
||
| echo "No suitable Ruby found. Installing ruby via rbenv..." | ||
| sudo apt-get install -y libz-dev libssl-dev libreadline-dev libyaml-dev libxml2-dev libxslt-dev | ||
| rbenv install 3.1.3 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 3.1.4 is now the latest 3.1.X |
||
| fi | ||
|
|
||
| if [ ! -f "$HOME/.config/hub" ]; then | ||
| echo "Ensure you have set up your GitHub access token in ~/.config/hub" | ||
| exit 1 | ||
| fi | ||
|
|
||
| GITHUB_TOKEN=$(ruby -e "require 'yaml'; puts YAML.load_file(Dir.home + '/.config/hub')['github.com'][0]['oauth_token']") | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Another reason to use |
||
|
|
||
| run_curl() { | ||
| ORGANISATION="bambooengineering" | ||
| REPO="umbrella" | ||
|
|
@@ -47,4 +72,4 @@ if [ "$code" != "200" ]; then | |
| exit 7 | ||
| fi | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This Something like: |
||
|
|
||
| ruby -e "$(run_curl)" | ||
| $HOME/.rbenv/shims/ruby -e "$(run_curl)" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you could say |
||
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.
Is
hubstill the recommended tool? I'm usingghwhich has ahub authcommand to help set it up (rather than manually creating its config file)