#!/usr/bin/env bash set -Eeuo pipefail cd "$(dirname "$(readlink -f "$BASH_SOURCE")")" versions=( "$@" ) if [ ${#versions[@]} -eq 0 ]; then versions=( */ ) fi versions=( "${versions[@]%/}" ) releasePage="$(curl -fsSL 'https://www.ruby-lang.org/en/downloads/releases/')" latest_gem_version() { curl -fsSL "https://rubygems.org/api/v1/gems/$1.json" | sed -r 's/^.*"version":"([^"]+)".*$/\1/' } rubygems="$(latest_gem_version rubygems-update)" bundler="$(latest_gem_version bundler)" travisEnv= 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 -E '&2 "warning: cannot determine sha for $version (tried all of ${allVersions[*]}); skipping" continue fi versionReleasePage="$(echo "$releasePage" | grep "Ruby $fullVersion" -A 2 | awk -F '"' '$1 == " "$dir/Dockerfile" if [ "$variant" = 'alpine3.4' ]; then sed -ri -e 's/libressl/openssl/g' "$dir/Dockerfile" fi case "$v" in */onbuild) ;; *) travisEnv='\n - VERSION='"$version VARIANT=$v$travisEnv" ;; esac done done travis="$(awk -v 'RS=\n\n' '$1 == "env:" { $0 = "env:'"$travisEnv"'" } { printf "%s%s", $0, RS }' .travis.yml)" echo "$travis" > .travis.yml