forked from docker-library/wordpress
-
Notifications
You must be signed in to change notification settings - Fork 0
/
versions.sh
executable file
·74 lines (67 loc) · 1.92 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
#!/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[@]%/}" )
for version in "${versions[@]}"; do
export version
doc='{}'
fullVersion=
if [ "$version" = 'cli' ]; then
possibleVersions=( $(
git ls-remote --tags 'https://github.com/wp-cli/wp-cli.git' \
| sed -r 's!^[^\t]+\trefs/tags/v([^^]+).*$!\1!g' \
| sort --version-sort --reverse
) )
for possibleVersion in "${possibleVersions[@]}"; do
url="https://github.com/wp-cli/wp-cli/releases/download/v${possibleVersion}/wp-cli-${possibleVersion}.phar.sha512"
if sha512="$(wget -qO- "$url" 2>/dev/null)" && [ -n "$sha512" ]; then
export sha512
doc="$(jq <<<"$doc" -c '.sha512 = env.sha512')"
fullVersion="$possibleVersion"
break
fi
done
else
possibleVersion="$(
wget -qO- "https://api.wordpress.org/core/version-check/1.7/?channel=$version" \
| jq -r '.offers[0].current'
)"
if [ -n "$possibleVersion" ] && sha1="$(wget -qO- "https://wordpress.org/wordpress-$possibleVersion.tar.gz.sha1")" && [ -n "$sha1" ]; then
fullVersion="$possibleVersion"
export sha1 fullVersion
doc="$(jq <<<"$doc" -c '.sha1 = env.sha1 | .upstream = env.fullVersion')"
if [[ "$fullVersion" != *.*.* && "$fullVersion" == *.* && "$fullVersion" != *-* ]]; then
fullVersion+='.0'
fi
fi
fi
if [ -z "$fullVersion" ]; then
echo >&2 "error: failed to find version for $version"
exit 1
fi
echo "$version: $fullVersion"
export fullVersion
json="$(
jq <<<"$json" -c --argjson doc "$doc" '
.[env.version] = {
version: env.fullVersion,
phpVersions: [ "8.0", "8.1", "8.2" ],
variants: (
if env.version == "cli" then
[ "alpine" ]
else
[ "apache", "fpm", "fpm-alpine" ]
end
),
} + $doc
'
)"
done
jq <<<"$json" -S . > versions.json