#!/usr/bin/env bash set -Eeuo pipefail cd "$(dirname "$(readlink -f "$BASH_SOURCE")")" versions=( "$@" ) if [ ${#versions[@]} -eq 0 ]; then versions=( */ ) json='{}' else json="$(< versions.json)" 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 for version in "${versions[@]}"; do rcGrepV='-v' rcVersion="${version%-rc}" if [ "$rcVersion" != "$version" ]; then rcGrepV= fi export version rcVersion 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 "