Skip to content

Commit 423cdaa

Browse files
committed
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.
1 parent 34c247b commit 423cdaa

File tree

3 files changed

+26
-12
lines changed

3 files changed

+26
-12
lines changed

generate-stackbrew-library.sh

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
#!/usr/bin/env bash
22
set -Eeuo pipefail
33

4-
declare -A aliases=(
5-
[4.1]='4 latest'
6-
[3.13]='3'
7-
)
84
defaultVariant='ubuntu'
95

106
self="$(basename "$BASH_SOURCE")"
@@ -14,7 +10,7 @@ if [ "$#" -eq 0 ]; then
1410
versions="$(jq -r '
1511
to_entries
1612
# sort version numbers with highest first
17-
| sort_by(.key | split("[.-]"; "") | map(try tonumber // .))
13+
| sort_by(.key | split("[.-]"; "") | map(tonumber? // .))
1814
| reverse
1915
| map(if .value then .key | @sh else empty end)
2016
| join(" ")
@@ -81,6 +77,8 @@ join() {
8177
echo "${out#$sep}"
8278
}
8379

80+
declare -A usedAliases=()
81+
8482
for version; do
8583
export version
8684
rcVersion="${version%-rc}"
@@ -103,16 +101,22 @@ for version; do
103101
versionAliases=()
104102
if [ "$version" = "$rcVersion" ]; then
105103
while [ "$fullVersion" != "$version" -a "${fullVersion%[.-]*}" != "$fullVersion" ]; do
106-
versionAliases+=( $fullVersion )
104+
versionAliases+=( "$fullVersion" )
107105
fullVersion="${fullVersion%[.-]*}"
108106
done
109107
else
110-
versionAliases+=( $fullVersion )
108+
versionAliases+=( "$fullVersion" )
109+
fi
110+
versionAliases+=( $version )
111+
112+
if [ "$version" = "$rcVersion" ]; then
113+
for tagAlias in "${fullVersion%%.*}" latest; do
114+
if [ -z "${usedAliases[$tagAlias]:-}" ]; then
115+
versionAliases+=( "$tagAlias" )
116+
usedAliases["$tagAlias"]="$version"
117+
fi
118+
done
111119
fi
112-
versionAliases+=(
113-
$version
114-
${aliases[$version]:-}
115-
)
116120

117121
for variant in ubuntu alpine; do
118122
dir="$version/$variant"

versions.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
"version": "4.1.3"
5454
},
5555
"4.1-rc": null,
56+
"4.2": null,
5657
"4.2-rc": {
5758
"alpine": {
5859
"version": "3.22"

versions.sh

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ for version in "${versions[@]}"; do
9696
if [[ "$fullVersion" == "$rcFullVersion"* ]] || [ "$latestVersion" = "$rcFullVersion" ]; then
9797
# "x.y.z-rc1" == x.y.z*
9898
echo >&2 "warning: skipping/removing '$version' ('$rcVersion' is at '$rcFullVersion' which is newer than '$fullVersion')"
99-
json="$(jq <<<"$json" -c '.[env.version] = null')"
10099
continue
101100
fi
102101
fi
@@ -184,6 +183,16 @@ for version in "${versions[@]}"; do
184183
}
185184
'
186185
)"
186+
187+
# make sure RCs and releases have corresponding pairs
188+
json="$(jq <<<"$json" -c '
189+
.[
190+
env.rcVersion
191+
+ if env.version == env.rcVersion then
192+
"-rc"
193+
else "" end
194+
] //= null
195+
')"
187196
done
188197

189198
jq <<<"$json" -S . > versions.json

0 commit comments

Comments
 (0)