74 lines
2.8 KiB
PowerShell
Raw Normal View History

2022-07-19 14:26:08 +05:30
# Function to add phalcon using GitHub releases.
Function Add-PhalconFromGitHub() {
Param (
[Parameter(Position = 0, Mandatory = $true)]
[ValidateNotNull()]
[string]
$Semver
)
$domain = 'https://github.com'
$nts = if (!$installed.ThreadSafe) { "_nts" } else { "" }
$match = Invoke-WebRequest -Uri "$domain/phalcon/cphalcon/releases/v$Semver" | Select-String -Pattern "href=`"(.*phalcon_x64_.*_php${version}_${extension_version}.*[0-9]${nts}.zip)`""
if($NULL -eq $match) {
$nts = if (!$installed.ThreadSafe) { "-nts" } else { "-ts" }
$match = Invoke-WebRequest -Uri "$domain/phalcon/cphalcon/releases/v$Semver" | Select-String -Pattern "href=`"(.*phalcon-php${version}${nts}-windows.*-x64.zip)`""
}
if($NULL -ne $match) {
2020-07-26 15:48:19 +05:30
$zip_file = $match.Matches[0].Groups[1].Value
2020-11-11 02:23:45 +05:30
Invoke-WebRequest -Uri $domain/$zip_file -OutFile $ENV:RUNNER_TOOL_CACHE\phalcon.zip > $null 2>&1
2020-07-26 15:48:19 +05:30
Expand-Archive -Path $ENV:RUNNER_TOOL_CACHE\phalcon.zip -DestinationPath $ENV:RUNNER_TOOL_CACHE\phalcon -Force > $null 2>&1
Copy-Item -Path "$ENV:RUNNER_TOOL_CACHE\phalcon\php_phalcon.dll" -Destination "$ext_dir\php_phalcon.dll"
Enable-PhpExtension -Extension phalcon -Path $php_dir
2022-07-19 14:26:08 +05:30
} else {
throw "Unable to get Phalcon release from the GitHub release"
}
}
# Function to install phalcon
Function Add-PhalconHelper() {
2022-10-24 03:35:44 +05:30
if (($extension_version -eq '4') -or ($extension_version -eq '5')) {
$extension_semver=Get-PeclPackageVersion phalcon $extension_version stable stable | Select-Object -First 1
Add-Extension -Extension phalcon -Stability stable -Extension_version $extension_semver
2022-07-19 14:26:08 +05:30
} elseif ($extension_version -eq '3') {
Add-PhalconFromGitHub -Semver 3.4.5
2020-07-26 15:48:19 +05:30
}
}
Function Add-Phalcon() {
Param (
2019-12-26 18:31:18 +05:30
[Parameter(Position = 0, Mandatory = $true)]
[ValidateNotNull()]
2022-07-19 14:26:08 +05:30
[ValidateSet('phalcon3', 'phalcon4', 'phalcon5')]
2019-12-26 18:31:18 +05:30
[string]
2020-07-26 15:48:19 +05:30
$extension
)
try {
$status = 'Enabled'
$extension_version = $extension.substring($extension.Length - 1)
2020-07-26 15:48:19 +05:30
if($extension_version -eq '4') {
if (Test-Path $ext_dir\php_psr.dll) {
Enable-PhpExtension -Extension psr -Path $php_dir
2020-07-26 15:48:19 +05:30
} else {
Install-Phpextension -Extension psr -MinimumStability stable -Path $php_dir
2020-07-26 15:48:19 +05:30
}
}
2020-07-26 15:48:19 +05:30
if(Test-Path $ext_dir\php_phalcon.dll) {
$phalcon = Get-PhpExtension $ext_dir\php_phalcon.dll
if($phalcon.Version[0] -eq $extension_version) {
Enable-PhpExtension -Extension phalcon -Path $php_dir
2020-07-26 15:48:19 +05:30
} else {
$status = 'Installed and enabled'
Remove-Item $ext_dir\php_phalcon.dll
2020-07-26 15:48:19 +05:30
Add-PhalconHelper
}
} else {
$status = 'Installed and enabled'
Add-PhalconHelper
}
2020-07-26 15:48:19 +05:30
Add-Log $tick $extension $status
} catch [Exception] {
Add-Log $cross $extension "Could not install $extension on PHP $($installed.FullVersion)"
}
}