Skip to content

Commit e3e46b4

Browse files
TimWollatianon
authored andcommitted
Use official JSON files as the source of truth in versions.sh
Resolves #184
1 parent 7191978 commit e3e46b4

File tree

7 files changed

+21
-42
lines changed

7 files changed

+21
-42
lines changed
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

generate-stackbrew-library.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ for version; do
7777

7878
# dcorbett(-haproxy): maybe just a simple "-dev" without the 0 which always follows the latest dev branch
7979
tagVersion="$version"
80-
if [[ "$version" == *-rc ]] && [[ "$fullVersion" == *-dev* ]]; then
81-
tagVersion="${version%-rc}-dev"
80+
if [[ "$fullVersion" == *-dev* ]]; then
81+
tagVersion="$version-dev"
8282
fi
8383

8484
versionAliases=(

versions.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
"url": "https://www.haproxy.org/download/2.6/src/haproxy-2.6.0.tar.gz",
4949
"version": "2.6.0"
5050
},
51-
"2.7-rc": {
51+
"2.7": {
5252
"alpine": "3.16",
5353
"debian": "bullseye-slim",
5454
"sha256": "75cfe3f3884cae05f93f0a91114b953de7aebba574c026e9d9106988fed34080",

versions.sh

Lines changed: 18 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -22,47 +22,26 @@ declare -A alpineVersion=(
2222
)
2323

2424
for version in "${versions[@]}"; do
25-
rcGrepV='-v'
26-
rcVersion="${version%-rc}"
27-
if [ "$rcVersion" != "$version" ]; then
28-
rcGrepV=
29-
fi
30-
31-
fullVersion="$(
32-
{
33-
curl -fsSL --compressed 'https://www.haproxy.org/download/'"$rcVersion"'/src/'
34-
if [ "$rcVersion" != "$version" ]; then
35-
curl -fsSL --compressed 'https://www.haproxy.org/download/'"$rcVersion"'/src/devel/'
36-
fi
37-
} \
38-
| grep -o '<a href="haproxy-'"$rcVersion"'[^"/]*\.tar\.gz"' \
39-
| sed -r 's!^<a href="haproxy-([^"/]+)\.tar\.gz"$!\1!' \
40-
| grep $rcGrepV -E 'rc|dev' \
41-
| sort -V \
42-
| tail -1
25+
export url="https://www.haproxy.org/download/$version/src"
26+
export debian="${debianSuite[$version]:-$defaultDebianSuite}"
27+
export alpine="${alpineVersion[$version]:-$defaultAlpineVersion}"
28+
29+
doc="$(
30+
curl -fsSL "$url/releases.json" | jq -c '
31+
{ version: .latest_release } + .releases[.latest_release]
32+
| {
33+
version: .version,
34+
url: (env.url + "/" + .file),
35+
sha256: .sha256,
36+
debian: env.debian,
37+
alpine: env.alpine,
38+
}
39+
'
4340
)"
44-
url="https://www.haproxy.org/download/$rcVersion/src"
45-
if [[ "$fullVersion" == *dev* ]]; then
46-
url+='/devel'
47-
fi
48-
url+="/haproxy-$fullVersion.tar.gz"
49-
sha256="$(curl -fsSL --compressed "$url.sha256" | cut -d' ' -f1)"
50-
51-
echo "$version: $fullVersion ($sha256, $url)"
52-
53-
versionSuite="${debianSuite[$version]:-$defaultDebianSuite}"
54-
alpine="${alpineVersion[$version]:-$defaultAlpineVersion}"
5541

56-
export version fullVersion sha256 url versionSuite alpine
57-
json="$(jq <<<"$json" -c '
58-
.[env.version] = {
59-
version: env.fullVersion,
60-
sha256: env.sha256,
61-
url: env.url,
62-
debian: env.versionSuite,
63-
alpine: env.alpine,
64-
}
65-
')"
42+
export version
43+
jq <<<"$doc" -r 'env.version + ": " + .version'
44+
json="$(jq <<<"$json" -c --argjson doc "$doc" '.[env.version] = $doc')"
6645
done
6746

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

0 commit comments

Comments
 (0)