@@ -8,49 +8,49 @@ source ~/utils/utils.sh
88
99arch=$( get_arch)
1010DEFAULT_RUBY_VERSION=$( get_toolset_value ' .ruby.default' )
11+ RUBY_PATH=$AGENT_TOOLSDIRECTORY /Ruby
12+ TOOLSET_VERSIONS=$( get_toolset_value ' .toolcache[] | select(.name | contains("Ruby")) | .arch.' $arch ' .versions[]' )
13+
1114echo " Installing Ruby..."
1215brew_smart_install " ruby@${DEFAULT_RUBY_VERSION} "
16+
17+ echo " Set Ruby ${DEFAULT_RUBY_VERSION} as default"
1318if [[ $arch == " arm64" ]]; then
1419 export PATH=/opt/homebrew/opt/ruby@${DEFAULT_RUBY_VERSION} /bin:$PATH
15- ruby_suffix=" macos-13-arm64"
1620else
1721 export PATH=/usr/local/opt/ruby@${DEFAULT_RUBY_VERSION} /bin:$PATH
18- ruby_suffix=" macos-latest"
1922fi
2023
24+ echo " Setting up gem environment"
2125GEM_PATH=$( gem env| awk ' /EXECUTABLE DIRECTORY/ {print $4}' )
2226echo " GEM_PATH=$GEM_PATH " >> $HOME /.bashrc
27+
2328if [[ $arch == " arm64" ]]; then
2429 echo ' export PATH="$GEM_PATH:/opt/homebrew/opt/ruby@' ${DEFAULT_RUBY_VERSION} ' /bin:$PATH"' >> $HOME /.bashrc
2530else
2631 echo ' export PATH="$GEM_PATH:/usr/local/opt/ruby@' ${DEFAULT_RUBY_VERSION} ' /bin:$PATH"' >> $HOME /.bashrc
2732fi
2833
29- echo " Install Ruby from toolset..."
30- [ -n " $API_PAT " ] && authString=(-H " Authorization: token ${API_PAT} " )
31- PACKAGE_TAR_NAMES=$( curl " ${authString[@]} " -fsSL " https://api.github.com/repos/ruby/ruby-builder/releases/latest" | jq -r ' .assets[].name' )
32- TOOLSET_VERSIONS=$( get_toolset_value ' .toolcache[] | select(.name | contains("Ruby")) | .arch.' $arch ' .versions[]' )
33- RUBY_PATH=$AGENT_TOOLSDIRECTORY /Ruby
34-
35- echo " Check if Ruby hostedtoolcache folder exists..."
34+ echo " Check if Ruby hostedtoolcache folder exists"
3635if [[ ! -d $RUBY_PATH ]]; then
37- mkdir -p $RUBY_PATH
36+ mkdir -p " $RUBY_PATH "
3837fi
39- echo " ruby path - $RUBY_PATH "
4038
4139for toolset_version in ${TOOLSET_VERSIONS[@]} ; do
42- package_tar_name=$( echo " $PACKAGE_TAR_NAMES " | grep " ^ruby-${toolset_version} -${ruby_suffix} .tar.gz$" | egrep -v " rc|preview" | sort -V | tail -1)
40+ echo " Installing Ruby version: $toolset_version ..."
41+ download_url=$( resolve_github_release_asset_url " ruby/ruby-builder" " contains(\" darwin-$arch .tar.gz\" )" " ruby-$toolset_version " " $API_PAT " )
42+ package_tar_name=" ${download_url##*/ } "
4343 ruby_version=$( echo " $package_tar_name " | cut -d' -' -f 2)
4444 ruby_version_path=" $RUBY_PATH /$ruby_version "
4545
46- echo " Create Ruby $ruby_version directory... "
47- mkdir -p $ruby_version_path
46+ echo " Create Ruby $ruby_version directory"
47+ mkdir -p " $ruby_version_path "
4848
4949 echo " Downloading tar archive $package_tar_name "
50- archive_path=$( download_with_retry " https://github.com/ruby/ruby-builder/releases/download/toolcache/ ${package_tar_name} " )
50+ archive_path=$( download_with_retry " $download_url " )
5151
5252 echo " Expand $package_tar_name to the $ruby_version_path folder"
53- tar xf $archive_path -C $ruby_version_path
53+ tar xf " $archive_path " -C " $ruby_version_path "
5454 complete_file_path=$ruby_version_path /$arch .complete
5555 if [[ ! -f $complete_file_path ]]; then
5656 echo " Create complete file"
0 commit comments