setup-php 2.16.0 → 2.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/README.md +159 -141
  2. package/lib/config.d.ts +3 -0
  3. package/lib/config.js +76 -0
  4. package/lib/config.js.map +1 -0
  5. package/lib/coverage.d.ts +5 -0
  6. package/lib/coverage.js +102 -0
  7. package/lib/coverage.js.map +1 -0
  8. package/lib/extensions.d.ts +4 -0
  9. package/lib/extensions.js +219 -0
  10. package/lib/extensions.js.map +1 -0
  11. package/lib/fetch.d.ts +1 -0
  12. package/lib/fetch.js +67 -0
  13. package/lib/fetch.js.map +1 -0
  14. package/lib/install.d.ts +2 -0
  15. package/lib/install.js +80 -0
  16. package/lib/install.js.map +1 -0
  17. package/lib/tools.d.ts +23 -0
  18. package/lib/tools.js +378 -0
  19. package/lib/tools.js.map +1 -0
  20. package/lib/utils.d.ts +21 -0
  21. package/lib/utils.js +266 -0
  22. package/lib/utils.js.map +1 -0
  23. package/package.json +21 -20
  24. package/src/config.ts +8 -8
  25. package/src/configs/brew_extensions +1 -0
  26. package/src/configs/composer.env +2 -0
  27. package/src/configs/ini/jit.ini +3 -0
  28. package/src/configs/ini/php.ini +2 -0
  29. package/src/configs/ini/xdebug.ini +1 -0
  30. package/src/configs/os_releases.csv +2 -0
  31. package/src/configs/php_packages +12 -0
  32. package/src/configs/tools.json +48 -26
  33. package/src/configs/tools_schema.json +11 -0
  34. package/src/coverage.ts +24 -49
  35. package/src/extensions.ts +28 -24
  36. package/src/fetch.ts +54 -0
  37. package/src/install.ts +28 -41
  38. package/src/scripts/darwin.sh +81 -33
  39. package/src/scripts/extensions/add_extensions.ps1 +194 -0
  40. package/src/scripts/extensions/add_extensions.sh +198 -0
  41. package/src/scripts/{ext → extensions}/blackfire.ps1 +0 -0
  42. package/src/scripts/{ext → extensions}/blackfire.sh +0 -0
  43. package/src/scripts/{ext → extensions}/couchbase.sh +0 -0
  44. package/src/scripts/{ext → extensions}/cubrid.sh +3 -3
  45. package/src/scripts/{ext → extensions}/extension_map.php +36 -13
  46. package/src/scripts/{ext → extensions}/firebird.ps1 +0 -0
  47. package/src/scripts/{ext → extensions}/firebird.sh +0 -0
  48. package/src/scripts/{ext → extensions}/gearman.sh +0 -0
  49. package/src/scripts/{ext → extensions}/geos.sh +0 -0
  50. package/src/scripts/{ext → extensions}/http.ps1 +1 -0
  51. package/src/scripts/{ext → extensions}/http.sh +13 -20
  52. package/src/scripts/{ext → extensions}/intl.sh +0 -0
  53. package/src/scripts/{ext → extensions}/ioncube.ps1 +2 -2
  54. package/src/scripts/{ext → extensions}/ioncube.sh +2 -2
  55. package/src/scripts/{ext → extensions}/oci.ps1 +39 -14
  56. package/src/scripts/{ext → extensions}/oci.sh +3 -3
  57. package/src/scripts/{ext → extensions}/patches/firebird.sh +0 -0
  58. package/src/scripts/{ext → extensions}/patches/geos.sh +0 -0
  59. package/src/scripts/{ext → extensions}/patches/http.sh +0 -0
  60. package/src/scripts/{ext → extensions}/patches/pdo_oci.sh +0 -0
  61. package/src/scripts/{ext → extensions}/patches/phpize.sh +0 -0
  62. package/src/scripts/{ext → extensions}/patches/protobuf.sh +0 -0
  63. package/src/scripts/{ext → extensions}/phalcon.ps1 +0 -0
  64. package/src/scripts/{ext → extensions}/phalcon.sh +4 -5
  65. package/src/scripts/{ext → extensions}/source.sh +36 -22
  66. package/src/scripts/extensions/sqlsrv.sh +15 -0
  67. package/src/scripts/linux.sh +76 -36
  68. package/src/scripts/tools/add_tools.ps1 +220 -10
  69. package/src/scripts/tools/add_tools.sh +164 -17
  70. package/src/scripts/tools/grpc_php_plugin.ps1 +4 -4
  71. package/src/scripts/tools/grpc_php_plugin.sh +3 -3
  72. package/src/scripts/tools/ppa.sh +12 -9
  73. package/src/scripts/tools/protoc.ps1 +2 -2
  74. package/src/scripts/tools/protoc.sh +2 -2
  75. package/src/scripts/tools/symfony.ps1 +18 -0
  76. package/src/scripts/tools/symfony.sh +18 -0
  77. package/src/scripts/unix.sh +186 -0
  78. package/src/scripts/win32.ps1 +137 -336
  79. package/src/tools.ts +62 -82
  80. package/src/utils.ts +57 -145
  81. package/src/scripts/common.sh +0 -366
@@ -0,0 +1,186 @@
1
+ # Variables
2
+ export tick="✓"
3
+ export cross="✗"
4
+ export curl_opts=(-sL)
5
+ export old_versions="5.[3-5]"
6
+ export jit_versions="8.[0-9]"
7
+ export nightly_versions="8.[2-9]"
8
+ export xdebug3_versions="7.[2-4]|8.[0-9]"
9
+ export latest="releases/latest/download"
10
+ export github="https://github.com/shivammathur"
11
+ export jsdeliver="https://cdn.jsdelivr.net/gh/shivammathur"
12
+ export setup_php="https://setup-php.com"
13
+
14
+ if [ -n "${GITHUB_ACTIONS}" ]; then
15
+ export GROUP='::group::'
16
+ export END_GROUP='::endgroup::'
17
+ else
18
+ export GROUP=''
19
+ export END_GROUP=''
20
+ fi
21
+
22
+ # Function to log start of a operation.
23
+ step_log() {
24
+ local message=$1
25
+ printf "\n\033[90;1m==> \033[0m\033[37;1m%s\033[0m\n" "$message"
26
+ }
27
+
28
+ # Function to log result of a operation.
29
+ add_log() {
30
+ local mark=$1
31
+ local subject=$2
32
+ local message=$3
33
+ if [ "$mark" = "$tick" ]; then
34
+ printf "\033[32;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s\033[0m\n" "$mark" "$subject" "$message"
35
+ else
36
+ printf "\033[31;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s\033[0m\n" "$mark" "$subject" "$message"
37
+ [ "$fail_fast" = "true" ] && exit 1
38
+ fi
39
+ }
40
+
41
+ # Function to set output on GitHub Actions.
42
+ set_output() {
43
+ name=$1
44
+ value=$2
45
+ if [ "${GITHUB_ACTIONS}" = "true" ]; then
46
+ echo "::set-output name=${name}::${value}"
47
+ fi
48
+ }
49
+
50
+ # Function to read env inputs.
51
+ read_env() {
52
+ update="${update:-${UPDATE:-false}}"
53
+ fail_fast="${fail_fast:-${FAIL_FAST:-false}}"
54
+ [[ -z "${ImageOS}" && -z "${ImageVersion}" ]] && _runner=self-hosted || _runner=github
55
+ runner="${runner:-${RUNNER:-$_runner}}"
56
+
57
+ if [[ "$runner" = "github" && $_runner = "self-hosted" ]]; then
58
+ fail_fast=true
59
+ add_log "$cross" "Runner" "Runner set as github in self-hosted environment"
60
+ fi
61
+ }
62
+
63
+ # Function to download a file using cURL.
64
+ # mode: -s pipe to stdout, -v save file and return status code
65
+ # execute: -e save file as executable
66
+ get() {
67
+ mode=$1
68
+ execute=$2
69
+ file_path=$3
70
+ shift 3
71
+ links=("$@")
72
+ if [ "$mode" = "-s" ]; then
73
+ sudo curl "${curl_opts[@]}" "${links[0]}"
74
+ else
75
+ for link in "${links[@]}"; do
76
+ status_code=$(sudo curl -w "%{http_code}" -o "$file_path" "${curl_opts[@]}" "$link")
77
+ [ "$status_code" = "200" ] && break
78
+ done
79
+ [ "$execute" = "-e" ] && sudo chmod a+x "$file_path"
80
+ [ "$mode" = "-v" ] && echo "$status_code"
81
+ fi
82
+ }
83
+
84
+ # Function to get shell profile.
85
+ get_shell_profile() {
86
+ case "$SHELL" in
87
+ *bash*)
88
+ echo "${HOME}/.bashrc"
89
+ ;;
90
+ *zsh*)
91
+ echo "${HOME}/.zshrc"
92
+ ;;
93
+ *)
94
+ echo "${HOME}/.profile"
95
+ ;;
96
+ esac
97
+ }
98
+
99
+ # Function to add a path to the PATH variable.
100
+ add_path() {
101
+ path_to_add=$1
102
+ [[ ":$PATH:" == *":$path_to_add:"* ]] && return
103
+ if [[ -n "$GITHUB_PATH" ]]; then
104
+ echo "$path_to_add" | tee -a "$GITHUB_PATH" >/dev/null 2>&1
105
+ else
106
+ profile=$(get_shell_profile)
107
+ ([ -e "$profile" ] && grep -q ":$path_to_add\"" "$profile" 2>/dev/null) || echo "export PATH=\"\${PATH:+\${PATH}:}\"$path_to_add" | sudo tee -a "$profile" >/dev/null 2>&1
108
+ fi
109
+ export PATH="${PATH:+${PATH}:}$path_to_add"
110
+ }
111
+
112
+ # Function to add environment variables using a PATH.
113
+ add_env_path() {
114
+ env_path=$1
115
+ [ -e "$env_path" ] || return
116
+ if [[ -n "$GITHUB_ENV" ]]; then
117
+ cat "$env_path" >> "$GITHUB_ENV"
118
+ else
119
+ profile=$(get_shell_profile)
120
+ cat "$env_path" >> "$profile"
121
+ fi
122
+ }
123
+
124
+ # Function to add an environment variable.
125
+ add_env() {
126
+ env_name=$1
127
+ env_value=$2
128
+ if [[ -n "$GITHUB_ENV" ]]; then
129
+ echo "$env_name=$env_value" | tee -a "$GITHUB_ENV" >/dev/null 2>&1
130
+ else
131
+ profile=$(get_shell_profile)
132
+ echo "export $env_name=\"$env_value\"" | sudo tee -a "$profile" >/dev/null 2>&1
133
+ fi
134
+ export "$env_name"="$env_value"
135
+ }
136
+
137
+ # Function to download and run scripts from GitHub releases with jsdeliver fallback.
138
+ run_script() {
139
+ repo=$1
140
+ shift
141
+ args=("$@")
142
+ get -q -e /tmp/install.sh "$github/$repo/$latest/install.sh" "$jsdeliver/$repo@main/scripts/install.sh" "$setup_php/$repo/install.sh"
143
+ bash /tmp/install.sh "${args[@]}"
144
+ }
145
+
146
+ # Function to install required packages on self-hosted runners.
147
+ self_hosted_setup() {
148
+ if [ "$runner" = "self-hosted" ]; then
149
+ if [[ "${version:?}" =~ $old_versions ]]; then
150
+ add_log "$cross" "PHP" "PHP $version is not supported on self-hosted runner"
151
+ exit 1
152
+ else
153
+ self_hosted_helper >/dev/null 2>&1
154
+ fi
155
+ fi
156
+ }
157
+
158
+ # Function to configure PHP
159
+ configure_php() {
160
+ add_php_config
161
+ ini_config_dir="${src:?}"/configs/ini
162
+ ini_files=("$ini_config_dir"/php.ini)
163
+ [[ "$version" =~ $jit_versions ]] && ini_files+=("$ini_config_dir"/jit.ini)
164
+ [[ "$version" =~ $xdebug3_versions ]] && ini_files+=("$ini_config_dir"/xdebug.ini)
165
+ cat "${ini_files[@]}" | sudo tee -a "${pecl_file:-${ini_file[@]}}" >/dev/null 2>&1
166
+ }
167
+
168
+ # Function to get PHP version in semver format.
169
+ php_semver() {
170
+ grep -Eo 'version="[0-9]+(\.[0-9]+){2}((-?[a-zA-Z]+([0-9]+)?)?){2}' "${php_config:?}" | cut -d '"' -f 2
171
+ }
172
+
173
+ # Function to get ini_path.
174
+ php_ini_path() {
175
+ cut -d '"' -f 2 < <(grep "ini_path=" "$php_config" || php --ini | grep '(php.ini)' | sed -e "s|.*: s*||")
176
+ }
177
+
178
+ # Function to get the tag for a php version.
179
+ php_src_tag() {
180
+ commit=$(php_extra_version | grep -Eo "[0-9a-zA-Z]+")
181
+ if [[ -n "${commit}" ]]; then
182
+ echo "$commit"
183
+ else
184
+ echo "php-${semver:?}"
185
+ fi
186
+ }