-
Notifications
You must be signed in to change notification settings - Fork 101
/
versions.sh
executable file
·76 lines (65 loc) · 1.69 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
#!/usr/bin/env bash
set -Eeuo pipefail
alpine="$(
bashbrew cat --format '{{ .TagEntry.Tags | join "\n" }}' https://github.com/docker-library/official-images/raw/HEAD/library/alpine:latest \
| grep -E '^[0-9]+[.][0-9]+$'
)"
[ "$(wc -l <<<"$alpine")" = 1 ]
export alpine
debian="$(
bashbrew cat --format '{{ .TagEntry.Tags | join "\n" }}' https://github.com/docker-library/official-images/raw/HEAD/library/debian:latest \
| grep -vE '^latest$|[0-9.-]' \
| head -1
)"
[ "$(wc -l <<<"$debian")" = 1 ]
export debian
cd "$(dirname "$(readlink -f "$BASH_SOURCE")")"
versions=( "$@" )
if [ ${#versions[@]} -eq 0 ]; then
versions=( */ )
json='{}'
else
json="$(< versions.json)"
fi
versions=( "${versions[@]%/}" )
possibles="$(
git ls-remote --tags 'https://github.com/memcached/memcached.git' \
| cut -d/ -f3- \
| cut -d^ -f1 \
| grep -E '^[0-9]+' \
| grep -vE -- '-(beta|rc)' \
| sort -urV
)"
for version in "${versions[@]}"; do
export version
versionPossibles="$(grep <<<"$possibles" -E "^$version([.-]|\$)")"
fullVersion=
sha1=
url=
for possible in $versionPossibles; do
url="https://memcached.org/files/memcached-$possible.tar.gz"
if sha1="$(curl -fsSL "$url.sha1")" && [ -n "$sha1" ]; then
sha1="${sha1%% *}"
fullVersion="$possible"
break
fi
done
if [ -z "$fullVersion" ]; then
echo >&2 "error: could not determine latest release for $version"
exit 1
fi
[ -n "$sha1" ]
[ -n "$url" ]
echo "$version: $fullVersion"
export fullVersion sha1 url
json="$(jq <<<"$json" -c '
.[env.version] = {
version: env.fullVersion,
url: env.url,
sha1: env.sha1,
alpine: { version: env.alpine },
debian: { version: env.debian },
}
')"
done
jq <<<"$json" . > versions.json