Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 15 additions & 11 deletions generate-stackbrew-library.sh
Original file line number Diff line number Diff line change
@@ -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")"
Expand All @@ -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(" ")
Expand Down Expand Up @@ -81,6 +77,8 @@ join() {
echo "${out#$sep}"
}

declare -A usedAliases=()

for version; do
export version
rcVersion="${version%-rc}"
Expand All @@ -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"
Expand Down
1 change: 1 addition & 0 deletions versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
"version": "4.1.3"
},
"4.1-rc": null,
"4.2": null,
"4.2-rc": {
"alpine": {
"version": "3.22"
Expand Down
11 changes: 10 additions & 1 deletion versions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Loading