#!/usr/bin/env bash set -Eeuo pipefail cd "$(dirname "$(readlink -f "$BASH_SOURCE")")" versions=( "$@" ) if [ ${#versions[@]} -eq 0 ]; then versions=( */ ) fi versions=( "${versions[@]%/}" ) releasesPage="$(curl -fsSL 'https://www.ruby-lang.org/en/downloads/releases/')" newsPage="$(curl -fsSL 'https://www.ruby-lang.org/en/news/')" # occasionally, releases don't show up on the Releases page (see https://github.com/ruby/www.ruby-lang.org/blob/master/_data/releases.yml) # TODO consider parsing https://github.com/ruby/www.ruby-lang.org/blob/master/_data/downloads.yml as well latest_gem_version() { curl -fsSL "https://rubygems.org/api/v1/gems/$1.json" | sed -r 's/^.*"version":"([^"]+)".*$/\1/' } # https://github.com/docker-library/ruby/issues/246 rubygems='3.0.3' declare -A newEnoughRubygems=( [2.6]=1 # 2.6.3 => gems 3.0.3 (https://github.com/ruby/ruby/blob/v2_6_3/lib/rubygems.rb#L12) [2.7]=1 # 2.7.0-preview2 => gems 3.1.0.pre1 (https://github.com/ruby/ruby/blob/v2_7_0_preview1/lib/rubygems.rb#L12) ) # TODO once all versions are in this family of "new enough", remove RUBYGEMS_VERSION code entirely for version in "${versions[@]}"; do rcGrepV='-v' rcVersion="${version%-rc}" if [ "$rcVersion" != "$version" ]; then rcGrepV= fi IFS=$'\n'; allVersions=( $( curl -fsSL --compressed "https://cache.ruby-lang.org/pub/ruby/$rcVersion/" \ | grep -oE '["/]ruby-'"$rcVersion"'.[^"]+\.tar\.xz' \ | sed -r 's!^["/]ruby-([^"]+)[.]tar[.]xz!\1!' \ | grep $rcGrepV -E 'preview|rc' \ | sort -ruV ) ); unset IFS fullVersion= shaVal= for tryVersion in "${allVersions[@]}"; do if \ { versionReleasePage="$(grep "