Skip to content

Commit 732e80b

Browse files
Ensure releases and RCs always have a corresponding pair
Also, adjust the way `versions.json` gets written for more human-powered field ordering.
1 parent f09075f commit 732e80b

File tree

1 file changed

+15
-16
lines changed

1 file changed

+15
-16
lines changed

versions.sh

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ set -Eeuo pipefail
33

44
cd "$(dirname "$(readlink -f "$BASH_SOURCE")")"
55

6+
# TODO consume https://www.php.net/releases/branches.php and https://www.php.net/release-candidates.php?format=json here like in Go, Julia, etc (so we can have a canonical "here's all the versions possible" mode, and more automated metadata like EOL 👀)
7+
68
versions=( "$@" )
79
if [ ${#versions[@]} -eq 0 ]; then
810
versions=( 8*/ )
@@ -52,16 +54,9 @@ for version in "${versions[@]}"; do
5254
unset IFS
5355

5456
if [ "${#possibles[@]}" -eq 0 ]; then
55-
if [ "$rcVersion" = "$version" ]; then
56-
echo >&2
57-
echo >&2 "error: unable to determine available releases of $version"
58-
echo >&2
59-
exit 1
60-
else
61-
echo >&2 "warning: skipping/removing '$version' (does not appear to exist upstream)"
62-
json="$(jq <<<"$json" -c '.[env.version] = null')"
63-
continue
64-
fi
57+
echo >&2 "warning: skipping/removing '$version' (does not appear to exist upstream)"
58+
json="$(jq <<<"$json" -c '.[env.version] = null')"
59+
continue
6560
fi
6661

6762
# format of "possibles" array entries is "VERSION URL.TAR.XZ URL.TAR.XZ.ASC SHA256" (each value shell quoted)
@@ -124,11 +119,15 @@ for version in "${versions[@]}"; do
124119
'
125120
)"
126121

127-
if [ "$version" = "$rcVersion" ]; then
128-
json="$(jq <<<"$json" -c '
129-
.[env.version + "-rc"] //= null
130-
')"
131-
fi
122+
# make sure RCs and releases have corresponding pairs
123+
json="$(jq <<<"$json" -c '
124+
.[
125+
env.version
126+
+ if env.version == env.rcVersion then
127+
"-rc"
128+
else "" end
129+
] //= null
130+
')"
132131
done
133132

134-
jq <<<"$json" -S . > versions.json
133+
jq <<<"$json" 'to_entries | sort_by(.key) | from_entries' > versions.json

0 commit comments

Comments
 (0)