From 784047f747a444121e90db5903b27d70ff1b398a Mon Sep 17 00:00:00 2001 From: Tianon Gravi Date: Tue, 30 Apr 2024 14:39:23 -0700 Subject: [PATCH] Skip "innovation" when any other release is newer We're in a temporary state where we have 8.4 as the freshly minted LTS and innovation still points to 8.3 (which is now "EOL") until 9.x -- this implementation ensures we bring innovation back automatically when it gets 9.x. See also https://dev.mysql.com/blog-archive/introducing-mysql-innovation-and-long-term-support-lts-versions/ especially the final graphic. --- generate-stackbrew-library.sh | 20 +++++++++++-- versions.json | 56 +++++++++++++++++------------------ versions.sh | 14 ++++++++- 3 files changed, 58 insertions(+), 32 deletions(-) diff --git a/generate-stackbrew-library.sh b/generate-stackbrew-library.sh index c370158ef..9119eb29e 100755 --- a/generate-stackbrew-library.sh +++ b/generate-stackbrew-library.sh @@ -3,7 +3,6 @@ set -Eeuo pipefail declare -A aliases=( [8.4]='lts' - [innovation]='latest' ) defaultDefaultVariant='oracle' @@ -14,6 +13,10 @@ declare -A defaultVariants=( self="$(basename "$BASH_SOURCE")" cd "$(dirname "$(readlink -f "$BASH_SOURCE")")" +# add the "latest" alias to the "newest" version (LTS vs innovation; see sorting in "versions.sh") +latest="$(jq -r 'keys_unsorted[0]' versions.json)" +aliases["$latest"]+=' latest' + if [ "$#" -eq 0 ]; then versions="$(jq -r 'keys | map(@sh) | join(" ")' versions.json)" eval "set -- $versions" @@ -64,8 +67,18 @@ join() { for version; do export version - defaultVariant="${defaultVariants[$version]:-$defaultDefaultVariant}" - fullVersion="$(jq -r '.[env.version].version' versions.json)" + if ! fullVersion="$(jq -re ' + if env.version == "innovation" and keys_unsorted[0] != env.version then + # https://github.com/docker-library/mysql/pull/1046#issuecomment-2087323746 + # if any explicit/LTS release is *newer* than the current innovation release, we should skip innovation + # (because we pre-sorted the full list in "versions.sh", we just need to check whether "innovation" is first 🚀) + false + else + .[env.version].version + end + ' versions.json)"; then + continue + fi versionAliases=() while [ "$fullVersion" != "$version" -a "${fullVersion%[.-]*}" != "$fullVersion" ]; do @@ -78,6 +91,7 @@ for version; do fi versionAliases+=( ${aliases[$version]:-} ) + defaultVariant="${defaultVariants[$version]:-$defaultDefaultVariant}" for variant in oracle debian; do export variant diff --git a/versions.json b/versions.json index a5a5e0d9f..a1ad17ea0 100644 --- a/versions.json +++ b/versions.json @@ -1,57 +1,57 @@ { - "8.0": { - "debian": { - "architectures": [ - "amd64" - ], - "suite": "bookworm", - "version": "8.0.37-1debian12" - }, - "mysql-shell": { - "repo": "https://repo.mysql.com/yum/mysql-tools-community/el/8", - "version": "8.0.37-1.el8" - }, + "8.4": { "oracle": { "architectures": [ "amd64", "arm64v8" ], - "repo": "https://repo.mysql.com/yum/mysql-8.0-community/docker/el/8", - "variant": "8-slim", - "version": "8.0.37-1.el8" + "repo": "https://repo.mysql.com/yum/mysql-8.4-community/docker/el/8", + "version": "8.4.0-1.el8", + "variant": "8-slim" }, - "version": "8.0.37" - }, - "8.4": { "mysql-shell": { "repo": "https://repo.mysql.com/yum/mysql-tools-8.4-community/el/8", "version": "8.4.0-1.el8" }, + "version": "8.4.0" + }, + "innovation": { "oracle": { "architectures": [ "amd64", "arm64v8" ], - "repo": "https://repo.mysql.com/yum/mysql-8.4-community/docker/el/8", - "variant": "8-slim", - "version": "8.4.0-1.el8" + "repo": "https://repo.mysql.com/yum/mysql-innovation-community/docker/el/8", + "version": "8.3.0-1.el8", + "variant": "8-slim" }, - "version": "8.4.0" - }, - "innovation": { "mysql-shell": { "repo": "https://repo.mysql.com/yum/mysql-tools-innovation-community/el/8", "version": "8.4.0-1.el8" }, + "version": "8.3.0" + }, + "8.0": { + "version": "8.0.37", + "debian": { + "architectures": [ + "amd64" + ], + "suite": "bookworm", + "version": "8.0.37-1debian12" + }, "oracle": { "architectures": [ "amd64", "arm64v8" ], - "repo": "https://repo.mysql.com/yum/mysql-innovation-community/docker/el/8", - "variant": "8-slim", - "version": "8.3.0-1.el8" + "repo": "https://repo.mysql.com/yum/mysql-8.0-community/docker/el/8", + "version": "8.0.37-1.el8", + "variant": "8-slim" }, - "version": "8.3.0" + "mysql-shell": { + "repo": "https://repo.mysql.com/yum/mysql-tools-community/el/8", + "version": "8.0.37-1.el8" + } } } diff --git a/versions.sh b/versions.sh index 10aaa1ae2..8c0f57ebd 100755 --- a/versions.sh +++ b/versions.sh @@ -172,4 +172,16 @@ for version in "${versions[@]}"; do json="$(jq <<<"$json" -c --argjson doc "$doc" '.[env.version] = $doc')" done -jq <<<"$json" -S . > versions.json +jq <<<"$json" ' + # sort entries in descending version order so that it is easier to determine later (in "generate-stackbrew-library.sh") if "innovation" should be included or not, and which entry to give the "latest" alias to (the first one!) + # https://github.com/docker-library/mysql/pull/1046#issuecomment-2087323746 + to_entries + | sort_by( + # very rough "sort by version number" + .value.version + | split(".") + | map(tonumber? // .) + ) + | reverse + | from_entries +' > versions.json