-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathruby-install.sh
77 lines (65 loc) · 2.33 KB
/
ruby-install.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/bin/bash
set -e
set -x
ruby_version=${1:-"2.5.3"}
gem_version=${2:-"2.7.7"}
ruby_archive="$ruby_version.tar.gz"
ruby_install_path="/home/runner/.rbenv/versions/$ruby_version"
semaphore_test_boosters="no"
if [ ! -e /home/runner/.rbenv ]
then
echo "*****************************************"
echo "Setting up rbenv"
echo "*****************************************"
# install the prerequisites
sudo apt-get update
sudo apt-get install -y autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm3 libgdbm-dev
# install rbenv & ruby-build
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
source ~/.bashrc
fi
if [ $(gem list | grep semaphore_test_boosters | wc -l) -gt 0 ]
then
semaphore_test_boosters="yes"
fi
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..."
if ! [ -d ~/.rbenv/versions ]; then mkdir ~/.rbenv/versions; fi
(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
if ! [ $gem_version = "$(gem --version)" ]; then
echo "Updating RubyGems to version $gem_version"
gem update --system $gem_version --no-ri --no-rdoc
fi
if [ ! -e $HOME/.rbenv/versions/$ruby_version/bin/bundle ]
then
echo "Installing bundler..."
gem install bundler --no-ri --no-rdoc
fi
if [ $semaphore_test_boosters == "yes" ]
then
echo "Installing Semaphore Test Boosters Gem..."
gem install semaphore_test_boosters
fi
echo "Setup complete."
echo "-----------------------------------------------"
echo "Details:"
echo "$(ruby --version)"
echo "$(bundle --version)"
echo "RubyGems version: $(gem --version)"