forked from php-stubs/wordpress-stubs
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrelease-latest-versions.sh
executable file
·54 lines (42 loc) · 1.44 KB
/
release-latest-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
#!/usr/bin/env bash
# @TODO See https://github.com/johnpbloch/build-wp/blob/master/files/run.sh
set -e
Do_release()
{
local VERSION="$1"
local SED_EXP
echo "Releasing ${VERSION} version ..."
if git rev-parse "refs/tags/v${VERSION}" >/dev/null 2>&1; then
echo "Tag exists!"
echo
return 0
fi
# Get new version
printf -v SED_EXP 's#\\("johnpbloch/wordpress"\\): "[0-9]\\+\\.[0-9]\\+\\.[0-9]\\+"#\\1: "%s"#' "${VERSION}"
sed -i -e "$SED_EXP" source/composer.json
composer run-script post-install-cmd
# Generate stubs
echo "Generating stubs ..."
./generate.sh
# Tag version
git commit --all -m "Generate stubs for WordPress ${VERSION}"
git tag "v${VERSION}"
}
CORE_JSON="$(wget -q -O- "https://packagist.org/packages/johnpbloch/wordpress-core.json")"
# @TODO Use branches!
#for MINOR in 4.7 4.8 4.9 \
# 5.0 5.1 5.2 5.3 5.4 5.5 5.6 5.7 5.8 5.9 \
for MINOR in \
6.0 6.1 6.2 6.3 6.4 6.5 6.6 6.7 6.8 6.9; do
# Find latest version
printf -v JQ_FILTER '.package.versions[].version | select(test("^%s\\\\.%s\\\\.\\\\d+$"))' "${MINOR%.*}" "${MINOR#*.}"
LATEST_FIVE="$(jq -r "$JQ_FILTER" <<<"$CORE_JSON" | sort -t "." -k 3 -g | tail -n 5)"
if [ -z "${LATEST_FIVE}" ]; then
echo "No version for ${MINOR}!"
echo
continue
fi
while read -r PATCH; do
Do_release "${PATCH}"
done <<<"${LATEST_FIVE}"
done