forked from php/php-windows-builder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathextension-matrix.sh
50 lines (40 loc) · 1.71 KB
/
extension-matrix.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
#!/usr/bin/env bash
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
. "$SCRIPT_DIR"/php-versions.sh
matrix=();
[ -z "$EXTENSION_URL" ] && EXTENSION_URL="https://github.com/${GITHUB_REPOSITORY:?}"
[ -z "$EXTENSION_REF" ] && EXTENSION_REF="${GITHUB_SHA:?}"
[ -z "$PHP_VERSION_LIST" ] && \
PHP_VERSION_LIST="$(get_php_versions "$EXTENSION_URL" "$EXTENSION_REF")"
[ -z "$ARCH_LIST" ] && ARCH_LIST="x64,x86"
[ -z "$TS_LIST" ] && TS_LIST="nts,ts"
IFS=',' read -r -a php_version_array <<<"${PHP_VERSION_LIST// /}"
IFS=',' read -r -a arch_array <<<"${ARCH_LIST// /}"
IFS=',' read -r -a ts_array <<<"${TS_LIST// /}"
vs_json="$SCRIPT_DIR"/../config/vs.json
filtered_versions=$(jq -r 'keys | join(" ")' "$vs_json")
if [[ -z "$ALLOW_OLD_PHP_VERSIONS" || "$ALLOW_OLD_PHP_VERSIONS" == "false" ]]; then
filtered_versions=$(jq -r 'to_entries | map(select(.value.type == "github-hosted") | .key) | join(" ")' "$vs_json")
fi
found='false'
for php_version in "${php_version_array[@]}"; do
if [[ " $filtered_versions " =~ $php_version ]]; then
found='true'
else
continue
fi
os=$(jq -r --arg php_version "$php_version" '.[$php_version].os' "$vs_json")
for arch in "${arch_array[@]}"; do
for ts in "${ts_array[@]}"; do
matrix+=("{\"os\": \"$os\", \"php-version\": \"$php_version\", \"arch\": \"$arch\", \"ts\": \"$ts\"}")
done
done
done
if [[ "$found" == 'false' ]]; then
echo "No PHP versions found for the specified inputs"
echo "Please refer to the PHP version support in the README"
echo "https://github.com/php/php-windows-builder#php-version-support"
exit 1
fi
# shellcheck disable=SC2001
echo "matrix={\"include\":[$(echo "${matrix[@]}" | sed -e 's|} {|}, {|g')]}" >> "$GITHUB_OUTPUT"