Created
January 18, 2018 10:20
-
-
Save nudded/de9f9ebdead36a4bc1e206e9406bb961 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env bash | |
. /home/runner/.bash_profile | |
ruby_version=${1:-"2.3.1"} | |
ruby_archive="$ruby_version.tar.gz" | |
ruby_install_path="/home/runner/.rbenv/versions/$ruby_version" | |
echo "*****************************************" | |
echo "Setting up Ruby $ruby_version" | |
echo "*****************************************" | |
if ! [ -d $ruby_install_path ]; then | |
if ! [ -e $SEMAPHORE_CACHE_DIR/$ruby_archive ]; then | |
cd /home/runner/.rbenv/plugins/ruby-build && git pull && cd - | |
CFLAGS='-fPIC' rbenv install $ruby_version | |
(cd $SEMAPHORE_CACHE_DIR && tar -cf $ruby_archive -C $ruby_install_path .) | |
else | |
echo "Ruby $ruby_version installation archive found in cache. Unpacking..." | |
(cd $SEMAPHORE_CACHE_DIR && mkdir $ruby_install_path && tar xf $ruby_archive -C $ruby_install_path) | |
fi | |
else | |
echo "Ruby $ruby_version already installed. Skipping setup..." | |
fi | |
echo "Activating Ruby $ruby_version" | |
rbenv global $ruby_version | |
echo "Setup complete." | |
echo "-----------------------------------------------" | |
echo "Details:" | |
echo "$(ruby --version)" | |
echo "$(bundle --version)" | |
echo "RubyGems version: $(gem --version)" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment