forked from docker-library/drupal
-
Notifications
You must be signed in to change notification settings - Fork 1
/
versions.sh
executable file
·119 lines (108 loc) · 2.84 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
#!/bin/bash
set -euo 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='{}'
rcGrepV='-v'
rcVersion="${version%-rc}"
if [ "$rcVersion" != "$version" ]; then
rcGrepV=
fi
case "$rcVersion" in
7)
# e.g. 7.x
drupalRelease="${rcVersion%%.*}.x"
;;
*)
# there is no https://updates.drupal.org/release-history/drupal/9.x
# (07/2020) current could also be used for 8.9, 9.x
drupalRelease='current'
;;
esac
fullVersion="$(
wget -qO- "https://updates.drupal.org/release-history/drupal/$drupalRelease" \
| awk -v RS='[<>]' '
$1 == "release" { release = 1; version = ""; mdhash = ""; tag = ""; next }
release && $1 ~ /^version|mdhash$/ { tag = $1; next }
release && tag == "version" { version = $1 }
release && tag == "mdhash" { mdhash = $1 }
release { tag = "" }
release && $1 == "/release" { release = 0; print version, mdhash }
' \
| grep -E "^${rcVersion}[. -]" \
| grep $rcGrepV -E -- '-rc|-beta|-alpha|-dev' \
| head -1
)"
if [ -z "$fullVersion" ]; then
echo >&2 "error: cannot find release for $version"
exit 1
fi
md5="${fullVersion##* }"
fullVersion="${fullVersion% $md5}"
if [ -n "$md5" ]; then
export md5
doc="$(jq <<<"$doc" -c '.md5 = env.md5')"
fi
composerVersion="$(
wget -qO- "https://github.com/drupal/drupal/raw/$fullVersion/composer.lock" \
| jq -r '
(.packages, ."packages-dev")[]
| select(.name == "composer/composer")
| .version
| split(".")[0:1] | join(".")
' \
|| :
)"
if [ "$version" != '7' ] && [ -z "$composerVersion" ]; then
echo >&2 "error: cannot find composer version for '$version' ('$fullVersion')"
exit 1
fi
if [ -n "$composerVersion" ]; then
export composerVersion
doc="$(jq <<<"$doc" -c '.composer = { version: env.composerVersion }')"
fi
echo "$version: $fullVersion${composerVersion:+ (composer $composerVersion)}"
export fullVersion
json="$(
jq <<<"$json" -c --argjson doc "$doc" '
.[env.version] = {
version: env.fullVersion,
variants: [
"bullseye",
"buster",
"alpine3.16",
"alpine3.15"
| if startswith("alpine") then empty else "apache-" + . end,
"fpm-" + .
],
phpVersions: (
# https://www.drupal.org/docs/system-requirements/php-requirements
# https://www.drupal.org/docs/7/system-requirements/php-requirements
if env.version == "7" then
[ "8.0", "7.4" ]
elif env.version | startswith("9.") then
[
"8.1",
"8.0",
"7.4"
]
else
# https://www.drupal.org/node/3264830
# Require PHP 8.1 for Drupal 10
[ "8.1" ]
end
),
} + $doc
'
)"
done
jq <<<"$json" -S . > versions.json