-
Notifications
You must be signed in to change notification settings - Fork 116
/
versions.sh
executable file
·62 lines (58 loc) · 1.88 KB
/
versions.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/usr/bin/env bash
set -Eeuo pipefail
doiCommit="$(git ls-remote https://github.com/docker-library/official-images.git HEAD | cut -d$'\t' -f1)"
doiPostgres="https://github.com/docker-library/official-images/raw/$doiCommit/library/postgres"
versions="$(
bashbrew list "$doiPostgres" | jq -nR '
[
inputs
# filter tags down to just "N-XXX" (capturing "version" and "debian suite")
| capture(":(?<version>[0-9]+)-(?<suite>[a-z].*)$")
| select(.suite | startswith("alpine") | not)
]
'
)"
supportedVersions="$(jq <<<"$versions" -r '[ .[].version | tonumber ] | unique | reverse | map(@sh) | join(" ")')"
eval "supportedVersions=( $supportedVersions )"
json='{}'
for i in "${!supportedVersions[@]}"; do
new="${supportedVersions[$i]}"
export new
suites="$(jq <<<"$versions" -c '[ .[] | select(.version == env.new).suite ]')"
echo "# $new (possible suites: $suites)"
(( j = i + 1 ))
for old in "${supportedVersions[@]:$j}"; do
export old
suite="$(jq <<<"$versions" --argjson suites "$suites" -r '
first(
.[]
| select(
.version == env.old
and (
.suite as $suite
| $suites | index($suite)
)
)
).suite
')"
from="postgres:$new-$suite"
dir="$old-to-$new"
export suite from dir
echo "- $old -> $new ($dir; $suite)"
postgresCommit="$(bashbrew cat --format '{{ .TagEntry.GitCommit }}' "$doiPostgres:$old-$suite")"
versionsURL="https://github.com/docker-library/postgres/raw/$postgresCommit/versions.json"
oldVersion="$(wget -qO- "$versionsURL" | jq -r '.[env.old][env.suite].version // empty')" # TODO arches? (would need to cross-reference $new's arches, but that's fair / not too difficult)
echo " - $oldVersion"
[ -n "$oldVersion" ]
export oldVersion
json="$(jq <<<"$json" -c '
.[env.dir] = {
from: env.from,
new: env.new,
old: env.old,
version: env.oldVersion,
}
')"
done
done
jq <<<"$json" '.' > versions.json