-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathstep.sh
executable file
·52 lines (42 loc) · 1.47 KB
/
step.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
#!/bin/bash
set -ex
function setup_rbenv {
platform="$(uname -s)"
case "${platform}" in
Darwin*) # macOS
brew update
brew outdated ruby-build || brew upgrade ruby-build
;;
Linux*)
# https://github.com/rbenv/rbenv-installer
curl -fsSL https://raw.githubusercontent.com/rbenv/rbenv-installer/main/bin/rbenv-installer | bash
PATH="/root/.rbenv/bin:${PATH}"
eval "$(rbenv init -)"
wget -q "https://raw.githubusercontent.com/rbenv/rbenv-installer/main/bin/rbenv-doctor" -O- | bash
envman add --key PATH --value "${PATH}"
;;
*)
echo "ERROR: Unknown platform found ${platform}"
;;
esac
curl -fsSL https://raw.githubusercontent.com/rbenv/rbenv-installer/main/bin/rbenv-doctor | bash
}
setup_rbenv
# Read .ruby-version
if [ -f .ruby-version ]; then
ruby_version_file=$(cat .ruby-version)
fi
# Determine Ruby version to be installed
version="${ruby_version:-${ruby_version_file}}"
# Install Ruby if not installed yet
rbenv install --skip-existing "${version}"
installed_dir="$(rbenv root)/versions/${version}"
# The way adding break lines looks odd here but this is the way we need to follow...
if [ "${BITRISE_CACHE_INCLUDE_PATHS}" == "" ]; then
cache_dir="
${installed_dir}"
else
cache_dir="${BITRISE_CACHE_INCLUDE_PATHS}
${installed_dir}"
fi
envman add --key BITRISE_CACHE_INCLUDE_PATHS --value "${cache_dir}"