forked from docker-library/rabbitmq
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathversions.sh
executable file
·142 lines (128 loc) · 4 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
#!/usr/bin/env bash
set -Eeuo pipefail
# https://www.rabbitmq.com/which-erlang.html ("Maximum supported Erlang/OTP")
declare -A otpMajors=(
[3.8]='24'
[3.9]='24'
)
# https://www.openssl.org/policies/releasestrat.html
# https://www.openssl.org/source/
declare -A opensslMajors=(
[3.8]='1.1'
[3.9]='1.1'
)
cd "$(dirname "$(readlink -f "$BASH_SOURCE")")"
versions=( "$@" )
if [ ${#versions[@]} -eq 0 ]; then
versions=( "${!otpMajors[@]}" )
# try RC releases after doing the non-RCs so we can check whether they're newer (and thus whether we should care)
versions+=( "${versions[@]/%/-rc}" )
json='{}'
else
json="$(< versions.json)"
fi
versions=( "${versions[@]%/}" )
for version in "${versions[@]}"; do
export version
rcVersion="${version%-rc}"
rcGrepV='-v'
if [ "$rcVersion" != "$version" ]; then
rcGrepV=
fi
rcGrepV+=' -E'
rcGrepExpr='beta|milestone|rc'
githubTags=( $(
git ls-remote --tags https://github.com/rabbitmq/rabbitmq-server.git \
"refs/tags/v${rcVersion}"{'','.*','-*','^*'} \
| cut -d'/' -f3- \
| cut -d'^' -f1 \
| grep $rcGrepV -- "$rcGrepExpr" \
| sort -urV
) )
fullVersion=
githubTag=
for possibleTag in "${githubTags[@]}"; do
fullVersion="$(
wget -qO- "https://github.com/rabbitmq/rabbitmq-server/releases/tag/$possibleTag" \
| grep -oE "/rabbitmq-server-generic-unix-${rcVersion}([.-].+)?[.]tar[.]xz" \
| head -1 \
| sed -r "s/^.*(${rcVersion}.*)[.]tar[.]xz/\1/" \
|| :
)"
if [ -n "$fullVersion" ]; then
githubTag="$possibleTag"
break
fi
done
if [ -z "$fullVersion" ] || [ -z "$githubTag" ]; then
echo >&2 "warning: failed to get full version for '$version'; skipping"
continue
fi
export fullVersion
# if this is a "-rc" release, let's make sure the release it contains isn't already GA (and thus something we should not publish anymore)
export rcVersion
if [ "$rcVersion" != "$version" ] && rcFullVersion="$(jq <<<"$json" -r '.[env.rcVersion].version // ""')" && [ -n "$rcFullVersion" ]; then
latestVersion="$({ echo "$fullVersion"; echo "$rcFullVersion"; } | sort -V | tail -1)"
if [[ "$fullVersion" == "$rcFullVersion"* ]] || [ "$latestVersion" = "$rcFullVersion" ]; then
# "x.y.z-rc1" == x.y.z*
echo >&2 "warning: skipping/removing '$version' ('$rcVersion' is at '$rcFullVersion' which is newer than '$fullVersion')"
json="$(jq <<<"$json" -c '.[env.version] = null')"
continue
fi
fi
otpMajor="${otpMajors[$rcVersion]}"
otpVersions=( $(
git ls-remote --tags https://github.com/erlang/otp.git \
"refs/tags/OTP-$otpMajor.*"\
| cut -d'/' -f3- \
| cut -d'^' -f1 \
| cut -d- -f2- \
| sort -urV
) )
otpVersion=
for possibleVersion in "${otpVersions[@]}"; do
if otpSourceSha256="$(
wget -qO- "https://github.com/erlang/otp/releases/download/OTP-$possibleVersion/SHA256.txt" \
| awk -v v="$possibleVersion" '$2 == "otp_src_" v ".tar.gz" { print $1 }'
)"; then
otpVersion="$possibleVersion"
break
fi
done
if [ -z "$otpVersion" ]; then
echo >&2 "warning: failed to get Erlang/OTP version for '$version' ($fullVersion); skipping"
continue
fi
export otpVersion otpSourceSha256
opensslMajor="${opensslMajors[$rcVersion]}"
opensslVersion="$(
wget -qO- 'https://www.openssl.org/source/' \
| grep -oE 'href="openssl-'"$opensslMajor"'[^"]+[.]tar[.]gz"' \
| sed -e 's/^href="openssl-//' -e 's/[.]tar[.]gz"//' \
| sort -uV \
| tail -1
)"
if [ -z "$opensslVersion" ]; then
echo >&2 "warning: failed to get OpenSSL version for '$version' ($fullVersion); skipping"
continue
fi
opensslSourceSha256="$(wget -qO- "https://www.openssl.org/source/openssl-$opensslVersion.tar.gz.sha256")"
export opensslVersion opensslSourceSha256
echo "$version: $fullVersion (otp $otpVersion, openssl $opensslVersion)"
json="$(
jq <<<"$json" -c '
.[env.version] = {
version: env.fullVersion,
openssl: {
version: env.opensslVersion,
sha256: env.opensslSourceSha256,
},
otp: {
version: env.otpVersion,
sha256: env.otpSourceSha256,
},
}
'
)"
done
jq <<<"$json" -S . > versions.json