-
Notifications
You must be signed in to change notification settings - Fork 161
/
Copy pathversions.sh
executable file
·48 lines (41 loc) · 1.17 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
#!/usr/bin/env bash
set -Eeuo pipefail
cd "$(dirname "$(readlink -f "$BASH_SOURCE")")"
versions=( "$@" )
if [ ${#versions[@]} -eq 0 ]; then
versions=( */ )
json='{}'
else
json="$(< versions.json)"
fi
versions=( "${versions[@]%/}" )
defaultDebianSuite='bookworm-slim'
declare -A debianSuite=(
[2.2]='bullseye-slim'
)
defaultAlpineVersion='3.21'
declare -A alpineVersion=(
)
for version in "${versions[@]}"; do
export version
export url="https://www.haproxy.org/download/$version/src"
export debian="${debianSuite[$version]:-$defaultDebianSuite}"
export alpine="${alpineVersion[$version]:-$defaultAlpineVersion}"
doc="$(
curl -fsSL "$url/releases.json" | jq -c '
{ version: .latest_release } + .releases[.latest_release]
| {
version: .version,
url: (env.url + "/" + .file),
sha256: .sha256,
debian: env.debian,
alpine: env.alpine,
}
# remove Alpine from versions where it cannot be built on any active Alpine release
| if env.version == "2.2" then del(.alpine) else . end
'
)"
jq <<<"$doc" -r 'env.version + ": " + .version'
json="$(jq <<<"$json" -c --argjson doc "$doc" '.[env.version] = $doc')"
done
jq <<<"$json" -S . > versions.json