setup-php 2.22.0 → 2.24.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 (38) hide show
  1. package/README.md +67 -67
  2. package/lib/coverage.js +11 -7
  3. package/lib/coverage.js.map +1 -1
  4. package/lib/extensions.js +12 -6
  5. package/lib/extensions.js.map +1 -1
  6. package/lib/tools.d.ts +1 -1
  7. package/lib/tools.js +8 -4
  8. package/lib/tools.js.map +1 -1
  9. package/lib/utils.js +8 -2
  10. package/lib/utils.js.map +1 -1
  11. package/package.json +16 -16
  12. package/src/configs/brew_extensions +6 -0
  13. package/src/configs/php-versions.json +3 -3
  14. package/src/configs/tools.json +8 -5
  15. package/src/configs/windows_extensions +2 -0
  16. package/src/coverage.ts +12 -16
  17. package/src/extensions.ts +27 -13
  18. package/src/scripts/darwin.sh +9 -6
  19. package/src/scripts/extensions/add_extensions.ps1 +72 -18
  20. package/src/scripts/extensions/firebird.ps1 +1 -1
  21. package/src/scripts/extensions/gearman.sh +6 -2
  22. package/src/scripts/extensions/http.ps1 +1 -6
  23. package/src/scripts/extensions/phalcon.ps1 +31 -7
  24. package/src/scripts/extensions/relay.sh +143 -0
  25. package/src/scripts/extensions/source.sh +1 -1
  26. package/src/scripts/extensions/sqlsrv.sh +6 -10
  27. package/src/scripts/extensions/zephir_parser.ps1 +79 -0
  28. package/src/scripts/extensions/zephir_parser.sh +37 -0
  29. package/src/scripts/linux.sh +2 -2
  30. package/src/scripts/tools/add_tools.ps1 +3 -3
  31. package/src/scripts/tools/add_tools.sh +3 -3
  32. package/src/scripts/tools/brew.sh +1 -1
  33. package/src/scripts/tools/grpc_php_plugin.ps1 +1 -1
  34. package/src/scripts/tools/protoc.ps1 +7 -5
  35. package/src/scripts/unix.sh +1 -1
  36. package/src/scripts/win32.ps1 +17 -5
  37. package/src/tools.ts +7 -6
  38. package/src/utils.ts +10 -2
@@ -1,5 +1,5 @@
1
- # Function to add phalcon using GitHub releases.
2
- Function Add-PhalconFromGitHub() {
1
+ # Function to get the url of the phalcon release asset.
2
+ Function Get-PhalconReleaseAssetUrl() {
3
3
  Param (
4
4
  [Parameter(Position = 0, Mandatory = $true)]
5
5
  [ValidateNotNull()]
@@ -7,14 +7,38 @@ Function Add-PhalconFromGitHub() {
7
7
  $Semver
8
8
  )
9
9
  $domain = 'https://api.github.com/repos'
10
- $nts = if (!$installed.ThreadSafe) { "_nts" } else { "" }
11
- $match = $match = (Invoke-RestMethod -Uri "$domain/phalcon/cphalcon/releases/tags/v$Semver").assets | Select-String -Pattern "browser_download_url=(.*phalcon_${arch}_.*_php${version}_${extension_version}.*[0-9]${nts}.zip)"
12
- if($NULL -eq $match) {
10
+ $releases = 'phalcon/cphalcon/releases'
11
+ if($extension_version -match '[3-4]') {
12
+ $nts = if (!$installed.ThreadSafe) { "_nts" } else { "" }
13
+ try {
14
+ $match = (Invoke-RestMethod -Uri "$domain/$releases/tags/v$Semver").assets | Select-String -Pattern "browser_download_url=.*(phalcon_${arch}_.*_php${version}_${extension_version}.*[0-9]${nts}.zip)"
15
+ } catch {
16
+ $match = (Invoke-WebRequest -Uri "$github/$releases/expanded_assets/v$Semver").Links.href | Select-String -Pattern "(phalcon_${arch}_.*_php${version}_${extension_version}.*[0-9]${nts}.zip)"
17
+ }
18
+ } else {
13
19
  $nts = if (!$installed.ThreadSafe) { "-nts" } else { "-ts" }
14
- $match = (Invoke-RestMethod -Uri "$domain/phalcon/cphalcon/releases/tags/v$Semver").assets | Select-String -Pattern "browser_download_url=(.*phalcon-php${version}${nts}-windows.*-x64.zip)"
20
+ try {
21
+ $match = (Invoke-RestMethod -Uri "$domain/$releases/tags/v$Semver").assets | Select-String -Pattern "browser_download_url=.*(phalcon-php${version}${nts}-windows.*-x64.zip)"
22
+ } catch {
23
+ $match = (Invoke-WebRequest -Uri "$github/$releases/expanded_assets/v$Semver").Links.href | Select-String -Pattern "(phalcon-php${version}${nts}-windows.*-x64.zip)"
24
+ }
15
25
  }
16
26
  if($NULL -ne $match) {
17
- $zip_url = $match.Matches[0].Groups[1].Value
27
+ return "$github/$releases/download/v$Semver/$($match.Matches[0].Groups[1].Value)"
28
+ }
29
+ return false;
30
+ }
31
+
32
+ # Function to add phalcon using GitHub releases.
33
+ Function Add-PhalconFromGitHub() {
34
+ Param (
35
+ [Parameter(Position = 0, Mandatory = $true)]
36
+ [ValidateNotNull()]
37
+ [string]
38
+ $Semver
39
+ )
40
+ $zip_url = Get-PhalconReleaseAssetUrl $Semver
41
+ if($zip_url) {
18
42
  Invoke-WebRequest -Uri $zip_url -OutFile $ENV:RUNNER_TOOL_CACHE\phalcon.zip > $null 2>&1
19
43
  Expand-Archive -Path $ENV:RUNNER_TOOL_CACHE\phalcon.zip -DestinationPath $ENV:RUNNER_TOOL_CACHE\phalcon -Force > $null 2>&1
20
44
  Copy-Item -Path "$ENV:RUNNER_TOOL_CACHE\phalcon\php_phalcon.dll" -Destination "$ext_dir\php_phalcon.dll"
@@ -0,0 +1,143 @@
1
+ # Get relay version
2
+ get_relay_version() {
3
+ local ext=$1
4
+ if [[ "$ext" =~ ^relay$ ]]; then
5
+ get -s -n "" "${relay_releases:?}"/latest 2<&1 | grep -m 1 -Eo "tag/(v[0-9]+(\.[0-9]+)?(\.[0-9]+)?)" | head -n 1 | cut -d '/' -f 2
6
+ else
7
+ relay_version="${ext##*-}"
8
+ echo "v${relay_version/v//}"
9
+ fi
10
+ }
11
+
12
+ # Get OS suffix in relay artifact URL.
13
+ get_os_suffix() {
14
+ if [ "$os" = "Linux" ]; then
15
+ if [[ "$ID" =~ ubuntu|debian ]]; then
16
+ echo debian
17
+ elif [ "$ID" = "centos" ]; then
18
+ echo centos"$VERSION_ID"
19
+ else
20
+ echo "$ID"
21
+ fi
22
+ else
23
+ echo darwin
24
+ fi
25
+ }
26
+
27
+ # Get openssl suffix in relay artifact URL.
28
+ get_openssl_suffix() {
29
+ openssl_3=$(php -r "echo strpos(OPENSSL_VERSION_TEXT, 'SSL 3') !== false;")
30
+ [ "$openssl_3" = "1" ] && echo '.libssl3' || echo ''
31
+ }
32
+
33
+ # Change library paths in relay binary.
34
+ change_library_paths() {
35
+ if [ "$os" = "Darwin" ]; then
36
+ otool -L "${ext_dir:?}"/relay.so | grep -q 'ssl.1' && openssl_version='1.1' || openssl_version='3'
37
+ [ -e "${brew_prefix:?}"/opt/openssl@"$openssl_version" ] || brew install openssl@"$openssl_version"
38
+ dylibs="$(otool -L "${ext_dir:?}"/relay.so | grep -Eo '.*\.dylib' | cut -f1 -d ' ')"
39
+ install_name_tool -change "$(echo "${dylibs}" | grep -E "libzstd.*dylib" | xargs)" "$brew_prefix"/opt/zstd/lib/libzstd.dylib "$ext_dir"/relay.so
40
+ install_name_tool -change "$(echo "${dylibs}" | grep -E "liblz4.*dylib" | xargs)" "$brew_prefix"/opt/lz4/lib/liblz4.dylib "$ext_dir"/relay.so
41
+ install_name_tool -change "$(echo "${dylibs}" | grep -E "libssl.*dylib" | xargs)" "$brew_prefix"/opt/openssl@"$openssl_version"/lib/libssl.dylib "$ext_dir"/relay.so
42
+ install_name_tool -change "$(echo "${dylibs}" | grep -E "libcrypto.*dylib" | xargs)" "$brew_prefix"/opt/openssl@"$openssl_version"/lib/libcrypto.dylib "$ext_dir"/relay.so
43
+ fi
44
+ }
45
+
46
+ # Add relay dependencies
47
+ add_relay_dependencies() {
48
+ add_extension json
49
+ add_extension msgpack
50
+ add_extension igbinary
51
+ if [ "$os" = "Darwin" ]; then
52
+ . "${0%/*}"/tools/brew.sh
53
+ configure_brew
54
+ brew install hiredis lz4 zstd
55
+ fi
56
+ }
57
+
58
+ # Initialize relay extension ini configuration
59
+ init_relay_ini() {
60
+ relay_ini=$1
61
+ if [ -e "$relay_ini" ]; then
62
+ if [[ -n "$RELAY_KEY" ]]; then
63
+ sudo sed -i.bak "s/^; relay.key =.*/relay.key = $RELAY_KEY/" "$relay_ini"
64
+ fi
65
+ if [[ -n "$RELAY_ENVIRONMENT" ]]; then
66
+ sudo sed -i.bak "s/^; relay.environment =.*/relay.environment = $RELAY_ENVIRONMENT/" "$relay_ini"
67
+ fi
68
+ if [[ -n "$RELAY_EVICTION_POLICY" ]]; then
69
+ sudo sed -i.bak "s/^; relay.eviction_policy =.*/relay.eviction_policy = $RELAY_EVICTION_POLICY/" "$relay_ini"
70
+ fi
71
+ if [[ -n "$RELAY_MAX_MEMORY" ]]; then
72
+ sudo sed -i.bak "s/^; relay.maxmemory =.*/relay.maxmemory = $RELAY_MAX_MEMORY/" "$relay_ini"
73
+ fi
74
+ sudo rm -rf "$relay_ini".bak
75
+ fi
76
+ }
77
+
78
+ # Enable relay extension
79
+ enable_relay() {
80
+ relay_ini=$1
81
+ if [ -e "$relay_ini" ]; then
82
+ init_relay_ini "$relay_ini"
83
+ if [ "$os" = "Linux" ]; then
84
+ sudo cp "$relay_ini" "${ini_dir:?}"/../mods-available/relay.ini
85
+ sudo phpenmod -v "${version:?}" relay
86
+ else
87
+ sudo cp "${relay_ini}" "${scan_dir:?}"/60-relay.ini
88
+ fi
89
+ fi
90
+ }
91
+
92
+ # Patch binary id in relay extension
93
+ init_relay_binary_id() {
94
+ if [ -e "${ext_dir:?}"/relay.so ]; then
95
+ grep -aq 00000000 "${ext_dir:?}"/relay.so && \
96
+ sudo LC_ALL=C sed -i.bak "s/00000000-0000-0000-0000-000000000000/$(uuidgen)/" "$ext_dir"/relay.so
97
+ fi
98
+ }
99
+
100
+ # Configure relay extension
101
+ configure_relay() {
102
+ change_library_paths
103
+ init_relay_binary_id
104
+ enable_relay "${ext_dir}"/relay.ini
105
+ }
106
+
107
+ # Helper function to add relay extension
108
+ add_relay_helper() {
109
+ arch="$(uname -m | sed 's/_/-/')"
110
+ os_suffix="$(get_os_suffix)"
111
+ openssl_suffix="$(get_openssl_suffix)"
112
+ artifact_file_name="relay-$relay_version-php${version:?}-$os_suffix-$arch$openssl_suffix.tar.gz"
113
+ url="$relay_releases"/download/"$relay_version"/"$artifact_file_name"
114
+ fallback_url="$relay_trunk"/"$artifact_file_name"
115
+ get -q -n /tmp/relay.tar.gz "$url" "$fallback_url"
116
+ if [ "$openssl_suffix" = '.libssl3' ] && (! [ -e /tmp/relay.tar.gz ] || ! file /tmp/relay.tar.gz | grep -q 'gzip'); then
117
+ get -q -n /tmp/relay.tar.gz "${url/.libssl3/}" "${fallback_url/.libssl3/}"
118
+ fi
119
+ if [ -e /tmp/relay.tar.gz ] && file /tmp/relay.tar.gz | grep -q 'gzip'; then
120
+ sudo tar --strip-components=1 -xzf /tmp/relay.tar.gz -C "${ext_dir:?}"
121
+ sudo mv "${ext_dir:?}"/relay-pkg.so "${ext_dir:?}"/relay.so
122
+ fi
123
+ }
124
+
125
+ # Add relay extension
126
+ add_relay() {
127
+ local ext=$1
128
+ local arch
129
+ local url
130
+ os=$(uname -s)
131
+ relay_releases=https://github.com/cachewerk/relay/releases
132
+ relay_trunk=https://builds.r2.relay.so
133
+ relay_version=$(get_relay_version "$ext")
134
+ add_relay_dependencies >/dev/null 2>&1
135
+ if shared_extension relay; then
136
+ message="Enabled"
137
+ else
138
+ add_relay_helper >/dev/null 2>&1
139
+ message="Installed and enabled"
140
+ fi
141
+ configure_relay >/dev/null 2>&1
142
+ add_extension_log relay "$message"
143
+ }
@@ -13,7 +13,7 @@ parse_args() {
13
13
  # Function to parse configure options for pecl
14
14
  # Make sure we have all options in name="value" form i.e XML properties.
15
15
  parse_pecl_configure_options() {
16
- configure_opts=$(echo "$1" | sed -r -e "s#['\"]|--##g")
16
+ configure_opts=$(echo "$1" | sed -E -e "s#['\"]|--##g")
17
17
  IFS=' ' read -r -a opts_array <<< "$configure_opts"
18
18
  output_opts=()
19
19
  for opt in "${opts_array[@]}"; do
@@ -7,18 +7,14 @@ get_sqlsrv_version() {
7
7
  fi
8
8
  }
9
9
 
10
- add_unixodbc() {
11
- if [ "$(uname -s)" = 'Linux' ]; then
12
- install_packages unixodbc-dev
13
- else
14
- brew install unixodbc
15
- fi
16
- }
17
-
18
10
  # Function to install sqlsrv and pdo_sqlsrv.
19
11
  add_sqlsrv() {
20
12
  ext=$1
21
13
  ext_version=$(get_sqlsrv_version)
22
- add_unixodbc >/dev/null 2>&1
23
- add_pecl_extension "$ext" "$ext_version" extension
14
+ if [ "$(uname -s)" = 'Linux' ]; then
15
+ install_packages unixodbc-dev
16
+ add_pecl_extension "$ext" "$ext_version" extension
17
+ else
18
+ add_brew_extension "$ext" extension
19
+ fi
24
20
  }
@@ -0,0 +1,79 @@
1
+ # Function to get the url of the phalcon release asset.
2
+ Function Get-ZephirParserReleaseAssetUrl() {
3
+ Param (
4
+ [Parameter(Position = 0, Mandatory = $true)]
5
+ [ValidateNotNull()]
6
+ [string]
7
+ $extension_version
8
+ )
9
+ $repo = 'zephir-lang/php-zephir-parser'
10
+ $zp_releases = "$github/$repo/releases"
11
+ try {
12
+ $match = (Invoke-RestMethod -Uri "https://api.github.com/repos/$repo/tags/$extension_version").assets | Select-String -Pattern "browser_download_url=.*(zephir_parser-php-${version}.*windows.*.zip)"
13
+ } catch {
14
+ $match = (Invoke-WebRequest -Uri "$zp_releases/expanded_assets/$extension_version").Links.href | Select-String -Pattern "(zephir_parser-php-${version}.*windows.*.zip)"
15
+ }
16
+ if($NULL -ne $match) {
17
+ return "$zp_releases/download/$extension_version/$($match.Matches[0].Groups[1].Value)"
18
+ }
19
+ return false;
20
+ }
21
+
22
+ # Function to get zephir parser version using GitHub releases.
23
+ Function Get-ZephirParserVersion() {
24
+ Param (
25
+ [Parameter(Position = 0, Mandatory = $true)]
26
+ [ValidateNotNull()]
27
+ [string]
28
+ $extension
29
+ )
30
+ $repo = 'zephir-lang/php-zephir-parser'
31
+ $zp_releases = "$github/$repo/releases"
32
+ if($extension -eq 'zephir_parser') {
33
+ return (Invoke-WebRequest -UseBasicParsing -Uri $zp_releases/latest).BaseResponse.RequestMessage.RequestUri.Segments[-1]
34
+ } else {
35
+ return 'v' + ($extension.split('-')[1] -replace 'v')
36
+ }
37
+ }
38
+
39
+ # Function to add zephir parser using GitHub releases.
40
+ Function Add-ZephirParserFromGitHub() {
41
+ Param (
42
+ [Parameter(Position = 0, Mandatory = $true)]
43
+ [ValidateNotNull()]
44
+ [string]
45
+ $extension
46
+ )
47
+ $extension_version = Get-ZephirParserVersion $extension
48
+ $zip_url = Get-ZephirParserReleaseAssetUrl $extension_version
49
+ if($zip_url) {
50
+ Invoke-WebRequest -Uri $zip_url -OutFile $ENV:RUNNER_TOOL_CACHE\zp.zip > $null 2>&1
51
+ Expand-Archive -Path $ENV:RUNNER_TOOL_CACHE\zp.zip -DestinationPath $ENV:RUNNER_TOOL_CACHE\zp -Force > $null 2>&1
52
+ Copy-Item -Path "$ENV:RUNNER_TOOL_CACHE\zp\php_zephir_parser.dll" -Destination "$ext_dir\php_zephir_parser.dll"
53
+ Enable-PhpExtension -Extension zephir_parser -Path $php_dir
54
+ } else {
55
+ throw "Unable to get zephir_parser release from the GitHub repo"
56
+ }
57
+ }
58
+
59
+ # Function to add zephir parser.
60
+ Function Add-ZephirParser() {
61
+ Param (
62
+ [Parameter(Position = 0, Mandatory = $true)]
63
+ [ValidateNotNull()]
64
+ [string]
65
+ $extension
66
+ )
67
+ try {
68
+ $status = 'Enabled'
69
+ if (Test-Path $ext_dir\php_zephir_parser.dll) {
70
+ Enable-PhpExtension -Extension zephir_parser -Path $php_dir
71
+ } else {
72
+ $status = 'Installed and enabled'
73
+ Add-ZephirParserFromGitHub $extension
74
+ }
75
+ Add-ExtensionLog zephir_parser $status
76
+ } catch {
77
+ Add-Log $cross $extension "Could not install $extension on PHP $($installed.FullVersion)"
78
+ }
79
+ }
@@ -0,0 +1,37 @@
1
+ # Get zephir_parser version
2
+ get_zephir_parser_version() {
3
+ local ext=$1
4
+ if [[ "$ext" =~ ^zephir_parser$ ]]; then
5
+ get -s -n "" "${zp_releases:?}"/latest 2<&1 | grep -m 1 -Eo "tag/(v?[0-9]+(\.[0-9]+)?(\.[0-9]+)?)" | head -n 1 | cut -d '/' -f 2
6
+ else
7
+ zp_version="${ext##*-}"
8
+ echo "v${zp_version/v//}"
9
+ fi
10
+ }
11
+
12
+ # Add zephir_parser helper
13
+ add_zephir_parser_helper() {
14
+ local ext=$1
15
+ ext_version=$(get_zephir_parser_version "$ext")
16
+ [ "$(uname -s)" = "Linux" ] && os_suffix=ubuntu || os_suffix=macos
17
+ build_name=$(get -s -n "" https://api.github.com/repos/"$repo"/releases/tags/"$ext_version" | grep -Eo "zephir_parser-php-${version:?}.*$os_suffix-.*.zip" | head -n 1)
18
+ [ -z "$build_name" ] && build_name=$(get -s -n "" "$zp_releases"/expanded_assets/"$ext_version" | grep -Eo "zephir_parser-php-${version:?}.*$os_suffix-.*.zip" | head -n 1)
19
+ get -q -e "/tmp/zp.zip" "$zp_releases"/download/"$ext_version"/"$build_name"
20
+ sudo unzip -o "/tmp/zp.zip" -d "${ext_dir:?}"
21
+ enable_extension zephir_parser extension
22
+ }
23
+
24
+ # Add zephir_parser
25
+ add_zephir_parser() {
26
+ ext=$1
27
+ repo=zephir-lang/php-zephir-parser
28
+ zp_releases=https://github.com/"$repo"/releases
29
+ if ! shared_extension zephir_parser; then
30
+ message='Installed and enabled'
31
+ add_zephir_parser_helper "$ext" >/dev/null 2>&1
32
+ else
33
+ message='Enabled'
34
+ enable_extension zephir_parser extension
35
+ fi
36
+ add_extension_log zephir_parser "$message"
37
+ }
@@ -2,7 +2,7 @@
2
2
  add_sudo() {
3
3
  if ! command -v sudo >/dev/null; then
4
4
  check_package sudo || apt-get update
5
- apt-get install -y sudo
5
+ apt-get install -y sudo || (apt-get update && apt-get install -y sudo)
6
6
  fi
7
7
  }
8
8
 
@@ -267,7 +267,7 @@ setup_php() {
267
267
  }
268
268
 
269
269
  # Variables
270
- version=${1:-'8.1'}
270
+ version=${1:-'8.2'}
271
271
  ini=${2:-'production'}
272
272
  src=${0%/*}/..
273
273
  debconf_fix="DEBIAN_FRONTEND=noninteractive"
@@ -183,7 +183,7 @@ Function Add-Tool() {
183
183
  }
184
184
  }
185
185
 
186
- Function Add-ComposertoolHelper() {
186
+ Function Add-ComposerToolHelper() {
187
187
  Param (
188
188
  [Parameter(Position = 0, Mandatory = $true)]
189
189
  [string]
@@ -234,7 +234,7 @@ Function Add-ComposertoolHelper() {
234
234
  }
235
235
 
236
236
  # Function to setup a tool using composer.
237
- Function Add-Composertool() {
237
+ Function Add-ComposerTool() {
238
238
  Param (
239
239
  [Parameter(Position = 0, Mandatory = $true)]
240
240
  [ValidateNotNull()]
@@ -267,7 +267,7 @@ Function Add-Composertool() {
267
267
  }
268
268
  }
269
269
  Enable-PhpExtension -Extension curl, mbstring, openssl -Path $php_dir
270
- $log = Add-ComposertoolHelper $tool $release $prefix $scope $composer_args
270
+ $log = Add-ComposerToolHelper $tool $release $prefix $scope $composer_args
271
271
  if(Test-Path $composer_bin\composer) {
272
272
  Copy-Item -Path "$bin_dir\composer" -Destination "$composer_bin\composer" -Force
273
273
  }
@@ -153,7 +153,7 @@ add_tool() {
153
153
  }
154
154
 
155
155
  # Function to setup a tool using composer in a different scope.
156
- add_composertool_helper() {
156
+ add_composer_tool_helper() {
157
157
  tool=$1
158
158
  release=$2
159
159
  prefix=$3
@@ -184,7 +184,7 @@ add_composertool_helper() {
184
184
  }
185
185
 
186
186
  # Function to setup a tool using composer.
187
- add_composertool() {
187
+ add_composer_tool() {
188
188
  tool=$1
189
189
  release=$2
190
190
  prefix=$3
@@ -199,7 +199,7 @@ add_composertool() {
199
199
  return
200
200
  fi
201
201
  fi
202
- add_composertool_helper "$tool" "$release" "$prefix" "$scope" "$composer_args"
202
+ add_composer_tool_helper "$tool" "$release" "$prefix" "$scope" "$composer_args"
203
203
  tool_version=$(get_tool_version cat /tmp/composer.log)
204
204
  ([ -s /tmp/composer.log ] && add_log "$tick" "$tool" "Added $tool $tool_version"
205
205
  ) || add_log "$cross" "$tool" "Could not setup $tool"
@@ -4,7 +4,7 @@ fetch_brew_tap() {
4
4
  tap_user=$(dirname "$tap")
5
5
  tap_name=$(basename "$tap")
6
6
  mkdir -p "$tap_dir/$tap_user"
7
- branch="$(get -s -n "" "https://api.github.com/repos/$tap" | grep default_branch | cut -d: -f 2 | grep -Eo '[^\", ]+' | tr -d '\n')"
7
+ branch="$(git ls-remote --symref "https://github.com/$tap" HEAD | grep -Eo 'refs/heads/.*' | tr '\t' '\n' | head -1 | cut -d '/' -f 3)"
8
8
  get -s -n "" "https://github.com/$tap/archive/$branch.tar.gz" | sudo tar -xzf - -C "$tap_dir/$tap_user"
9
9
  sudo mv "$tap_dir/$tap_user/$tap_name-$branch" "$tap_dir/$tap_user/$tap_name"
10
10
  }
@@ -7,7 +7,7 @@ Function Add-Msys2() {
7
7
  return $msys_location
8
8
  }
9
9
 
10
- Function Add-Grpc_php_plugin() {
10
+ Function Add-GrpcPhpPlugin() {
11
11
  $msys_location = Add-Msys2
12
12
  $logs = . $msys_location\usr\bin\bash -l -c "pacman -S --noconfirm mingw-w64-x86_64-grpc" >$null 2>&1
13
13
  $grpc_version = Get-ToolVersion 'Write-Output' "$logs"
@@ -1,15 +1,17 @@
1
1
  Function Get-ProtobufTag() {
2
+ $releases = 'https://github.com/protocolbuffers/protobuf/releases'
2
3
  if("$protobuf_tag" -eq "latest") {
3
- $protobuf_tag = (Invoke-RestMethod https://api.github.com/repos/protocolbuffers/protobuf/releases).tag_name | Where-Object { $_ -match "v\d+.\d+.\d+$" } | Select-Object -First 1
4
+ $protobuf_tag = (Invoke-WebRequest -UseBasicParsing -Uri $releases/latest).BaseResponse.RequestMessage.RequestUri.Segments[-1]
4
5
  } else {
5
6
  try {
6
- [net.httpWebRequest] $request = [net.webRequest]::create("https://github.com/protocolbuffers/protobuf/releases/tag/v$protobuf_tag")
7
- $req.Method = "HEAD"
7
+ $protobuf_tag = $protobuf_tag -replace '^v', ''
8
+ [net.httpWebRequest] $request = [net.webRequest]::create("$releases/tag/v$protobuf_tag")
9
+ $request.Method = "HEAD"
8
10
  [net.httpWebResponse] $response = $request.getResponse()
9
11
  $response.Close()
10
12
  $protobuf_tag = "v$protobuf_tag"
11
13
  } catch {
12
- $protobuf_tag = (Invoke-RestMethod https://api.github.com/repos/protocolbuffers/protobuf/releases).tag_name | Where-Object { $_ -match "v\d+.\d+.\d+$" } | Select-Object -First 1
14
+ $protobuf_tag = (Invoke-WebRequest -UseBasicParsing -Uri $releases/latest).BaseResponse.RequestMessage.RequestUri.Segments[-1]
13
15
  }
14
16
  }
15
17
  return $protobuf_tag
@@ -18,7 +20,7 @@ Function Get-ProtobufTag() {
18
20
  Function Add-Protoc() {
19
21
  param(
20
22
  [Parameter(Mandatory = $true, Position = 0, HelpMessage = 'The PHP version to be installed')]
21
- [ValidatePattern('^latest$|^(v?)\d+\.\d+\.\d+$')]
23
+ [ValidatePattern('^latest$|^(v?)\d+\.\d+(\.\d+)?$')]
22
24
  [string] $protobuf_tag
23
25
  )
24
26
  $protobuf_tag = Get-ProtobufTag
@@ -4,7 +4,7 @@ export cross="✗"
4
4
  export curl_opts=(-sL)
5
5
  export old_versions="5.[3-5]"
6
6
  export jit_versions="8.[0-9]"
7
- export nightly_versions="8.[2-9]"
7
+ export nightly_versions="8.[3-9]"
8
8
  export xdebug3_versions="7.[2-4]|8.[0-9]"
9
9
  export latest="releases/latest/download"
10
10
  export github="https://github.com/shivammathur"
@@ -3,7 +3,7 @@ param (
3
3
  [ValidateNotNull()]
4
4
  [ValidateLength(1, [int]::MaxValue)]
5
5
  [string]
6
- $version = '8.1',
6
+ $version = '8.2',
7
7
  [Parameter(Position = 1, Mandatory = $true)]
8
8
  [ValidateNotNull()]
9
9
  [ValidateLength(1, [int]::MaxValue)]
@@ -218,10 +218,22 @@ Function Add-PhpConfig {
218
218
  # Function to get PHP from GitHub releases cache
219
219
  Function Set-PhpCache {
220
220
  try {
221
- $release = Invoke-RestMethod https://api.github.com/repos/shivammathur/php-builder-windows/releases/tags/php$version
222
- $asset = $release.assets | ForEach-Object {
223
- if($_.name -match "php-$version.[0-9]+$env:PHPTS-Win32-.*-$arch.zip") {
224
- return $_.name
221
+ try {
222
+ $release = Invoke-RestMethod https://api.github.com/repos/shivammathur/php-builder-windows/releases/tags/php$version
223
+ $asset = $release.assets | ForEach-Object {
224
+ if($_.name -match "php-$version.[0-9]+$env:PHPTS-Win32-.*-$arch.zip") {
225
+ return $_.name
226
+ }
227
+ }
228
+ if($null -eq $asset) {
229
+ throw "Asset not found"
230
+ }
231
+ } catch {
232
+ $release = Invoke-WebRequest $php_builder/releases/expanded_assets/php$version
233
+ $asset = $release.links.href | ForEach-Object {
234
+ if($_ -match "php-$version.[0-9]+$env:PHPTS-Win32-.*-$arch.zip") {
235
+ return $_.split('/')[-1]
236
+ }
225
237
  }
226
238
  }
227
239
  Invoke-WebRequest -UseBasicParsing -Uri $php_builder/releases/download/php$version/$asset -OutFile $php_dir\$asset
package/src/tools.ts CHANGED
@@ -201,7 +201,7 @@ export async function addArchive(data: RS): Promise<string> {
201
201
  * @param data
202
202
  */
203
203
  export async function addPackage(data: RS): Promise<string> {
204
- const command = await utils.getCommand(data['os'], 'composertool');
204
+ const command = await utils.getCommand(data['os'], 'composer_tool');
205
205
  const parts: string[] = data['repository'].split('/');
206
206
  const args: string = await utils.joins(
207
207
  parts[1],
@@ -218,11 +218,12 @@ export async function addPackage(data: RS): Promise<string> {
218
218
  * @param data
219
219
  */
220
220
  export async function addBlackfirePlayer(data: RS): Promise<string> {
221
- if (
222
- /5\.[5-6]|7\.0/.test(data['php_version']) &&
223
- data['version'] == 'latest'
224
- ) {
225
- data['version'] = '1.9.3';
221
+ if (data['version'] == 'latest') {
222
+ if (/5\.[5-6]|7\.0/.test(data['php_version'])) {
223
+ data['version'] = '1.9.3';
224
+ } else if (/7\.[1-4]|8\.0/.test(data['php_version'])) {
225
+ data['version'] = '1.22.0';
226
+ }
226
227
  }
227
228
  data['url'] = await getPharUrl(data);
228
229
  return addArchive(data);
package/src/utils.ts CHANGED
@@ -246,7 +246,8 @@ export async function CSVArray(values_csv: string): Promise<Array<string>> {
246
246
  return value
247
247
  .trim()
248
248
  .replace(/^["']|["']$|(?<==)["']/g, '')
249
- .replace(/=(((?!E_).)*[?{}|&~![()^]+((?!E_).)+)/, "='$1'");
249
+ .replace(/=(((?!E_).)*[?{}|&~![()^]+((?!E_).)+)/, "='$1'")
250
+ .replace(/=(.*?)(=.*)/, "='$1$2'");
250
251
  })
251
252
  .filter(Boolean);
252
253
  }
@@ -319,7 +320,14 @@ export async function getCommand(os: string, suffix: string): Promise<string> {
319
320
  case 'darwin':
320
321
  return 'add_' + suffix + ' ';
321
322
  case 'win32':
322
- return 'Add-' + suffix.charAt(0).toUpperCase() + suffix.slice(1) + ' ';
323
+ return (
324
+ 'Add-' +
325
+ suffix
326
+ .split('_')
327
+ .map((part: string) => part.charAt(0).toUpperCase() + part.slice(1))
328
+ .join('') +
329
+ ' '
330
+ );
323
331
  default:
324
332
  return await log('Platform ' + os + ' is not supported', os, 'error');
325
333
  }