Choose correct ts build for zephir_parser

This commit is contained in:
Shivam Mathur 2023-02-09 15:41:48 +05:30
parent 1224b29111
commit 0d60024683
No known key found for this signature in database
GPG Key ID: 3E13E4C8591ACC2A
2 changed files with 6 additions and 4 deletions

View File

@ -8,10 +8,11 @@ Function Get-ZephirParserReleaseAssetUrl() {
) )
$repo = 'zephir-lang/php-zephir-parser' $repo = 'zephir-lang/php-zephir-parser'
$zp_releases = "$github/$repo/releases" $zp_releases = "$github/$repo/releases"
$nts = if (!$installed.ThreadSafe) { "nts" } else { "ts" }
try { try {
$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)" $match = (Invoke-RestMethod -Uri "https://api.github.com/repos/$repo/tags/$extension_version").assets | Select-String -Pattern "browser_download_url=.*(zephir_parser-php-${version}-$nts-windows.*.zip)"
} catch { } catch {
$match = (Get-File -Url "$zp_releases/expanded_assets/$extension_version").Links.href | Select-String -Pattern "(zephir_parser-php-${version}.*windows.*.zip)" $match = (Get-File -Url "$zp_releases/expanded_assets/$extension_version").Links.href | Select-String -Pattern "(zephir_parser-php-${version}-$nts-windows.*.zip)"
} }
if($NULL -ne $match) { if($NULL -ne $match) {
return "$zp_releases/download/$extension_version/$($match.Matches[0].Groups[1].Value)" return "$zp_releases/download/$extension_version/$($match.Matches[0].Groups[1].Value)"

View File

@ -12,10 +12,11 @@ get_zephir_parser_version() {
# Add zephir_parser helper # Add zephir_parser helper
add_zephir_parser_helper() { add_zephir_parser_helper() {
local ext=$1 local ext=$1
nts="${ts:?}" && nts="${nts/z/}"
ext_version=$(get_zephir_parser_version "$ext") ext_version=$(get_zephir_parser_version "$ext")
[ "$(uname -s)" = "Linux" ] && os_suffix=ubuntu || os_suffix=macos [ "$(uname -s)" = "Linux" ] && os_suffix=ubuntu || os_suffix=macos
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) build_name=$(get -s -n "" https://api.github.com/repos/"$repo"/releases/tags/"$ext_version" | grep -Eo "zephir_parser-php-${version:?}-$nts-$os_suffix-.*.zip" | head -n 1)
[ -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) [ -z "$build_name" ] && build_name=$(get -s -n "" "$zp_releases"/expanded_assets/"$ext_version" | grep -Eo "zephir_parser-php-${version:?}-$nts-$os_suffix-.*.zip" | head -n 1)
get -q -e "/tmp/zp.zip" "$zp_releases"/download/"$ext_version"/"$build_name" get -q -e "/tmp/zp.zip" "$zp_releases"/download/"$ext_version"/"$build_name"
sudo unzip -o "/tmp/zp.zip" -d "${ext_dir:?}" sudo unzip -o "/tmp/zp.zip" -d "${ext_dir:?}"
enable_extension zephir_parser extension enable_extension zephir_parser extension