Make alias-choosing code generic so GA can be fully automated

This means that when 4.2 is GA, our update automation should pick it up automatically, and update `latest` and `4` to point to it.
This commit is contained in:
Tianon Gravi 2025-08-08 13:48:32 -07:00
parent 34c247bc2a
commit 423cdaa94f
3 changed files with 26 additions and 12 deletions

View File

@ -1,10 +1,6 @@
#!/usr/bin/env bash
set -Eeuo pipefail
declare -A aliases=(
[4.1]='4 latest'
[3.13]='3'
)
defaultVariant='ubuntu'
self="$(basename "$BASH_SOURCE")"
@ -14,7 +10,7 @@ if [ "$#" -eq 0 ]; then
versions="$(jq -r '
to_entries
# sort version numbers with highest first
| sort_by(.key | split("[.-]"; "") | map(try tonumber // .))
| sort_by(.key | split("[.-]"; "") | map(tonumber? // .))
| reverse
| map(if .value then .key | @sh else empty end)
| join(" ")
@ -81,6 +77,8 @@ join() {
echo "${out#$sep}"
}
declare -A usedAliases=()
for version; do
export version
rcVersion="${version%-rc}"
@ -103,16 +101,22 @@ for version; do
versionAliases=()
if [ "$version" = "$rcVersion" ]; then
while [ "$fullVersion" != "$version" -a "${fullVersion%[.-]*}" != "$fullVersion" ]; do
versionAliases+=( $fullVersion )
versionAliases+=( "$fullVersion" )
fullVersion="${fullVersion%[.-]*}"
done
else
versionAliases+=( $fullVersion )
versionAliases+=( "$fullVersion" )
fi
versionAliases+=( $version )
if [ "$version" = "$rcVersion" ]; then
for tagAlias in "${fullVersion%%.*}" latest; do
if [ -z "${usedAliases[$tagAlias]:-}" ]; then
versionAliases+=( "$tagAlias" )
usedAliases["$tagAlias"]="$version"
fi
done
fi
versionAliases+=(
$version
${aliases[$version]:-}
)
for variant in ubuntu alpine; do
dir="$version/$variant"

View File

@ -53,6 +53,7 @@
"version": "4.1.3"
},
"4.1-rc": null,
"4.2": null,
"4.2-rc": {
"alpine": {
"version": "3.22"

View File

@ -96,7 +96,6 @@ for version in "${versions[@]}"; do
if [[ "$fullVersion" == "$rcFullVersion"* ]] || [ "$latestVersion" = "$rcFullVersion" ]; then
# "x.y.z-rc1" == x.y.z*
echo >&2 "warning: skipping/removing '$version' ('$rcVersion' is at '$rcFullVersion' which is newer than '$fullVersion')"
json="$(jq <<<"$json" -c '.[env.version] = null')"
continue
fi
fi
@ -184,6 +183,16 @@ for version in "${versions[@]}"; do
}
'
)"
# make sure RCs and releases have corresponding pairs
json="$(jq <<<"$json" -c '
.[
env.rcVersion
+ if env.version == env.rcVersion then
"-rc"
else "" end
] //= null
')"
done
jq <<<"$json" -S . > versions.json