diff --git a/generate-stackbrew-library.sh b/generate-stackbrew-library.sh index 3a3c36a717..64c69c6d32 100755 --- a/generate-stackbrew-library.sh +++ b/generate-stackbrew-library.sh @@ -1,5 +1,7 @@ -#!/usr/local/Cellar/bash/4.3.30/bin/bash +#!/bin/bash + set -e +shopt -s extglob declare -A aliases aliases=( @@ -7,19 +9,46 @@ aliases=( [1.580.3]='latest' ) -versions=( */ ) -versions=( "${versions[@]%/}" ) +versions() { + local IFS=$'\n' + local versions=( "${@%/}" ) + sort -Vr <<< "${versions[*]}" +} + +lts_versions=( $(versions *.*.*/) ) +weekly_versions=( $(versions !(*.*.*)/) ) url='git://github.com/cloudbees/jenkins-ci.org-docker' echo '# maintainer: Nicolas De Loof (@ndeloof)' echo '# maintainer: Michael Neale (@michaelneale)' echo -for version in "${versions[@]}"; do - commit="$(git log -1 --format='format:%H' -- "$version")" - versionAliases=( $version ${aliases[$version]} ) - - for va in "${versionAliases[@]}"; do +echo "# group: Current Releases" +for current in $(IFS=$'\n'; sort -V <<< "${!aliases[*]}"); do + commit="$(git log -1 --format='format:%H' -- "$current")" + for va in "$current" ${aliases[$current]}; do echo "$va: ${url}@${commit} $version" done + echo +done + +echo "# group: Previous LTS Releases" +for version in "${lts_versions[@]}"; do + if [ "${aliases[$version]}" ]; then + continue + fi + + commit="$(git log -1 --format='format:%H' -- "$version")" + echo "$version: ${url}@${commit} $version" +done +echo + +echo "# group: Previous Weekly Releases" +for version in "${weekly_versions[@]}"; do + if [ "${aliases[$version]}" ]; then + continue + fi + + commit="$(git log -1 --format='format:%H' -- "$version")" + echo "$version: ${url}@${commit} $version" done