Skip to content

Check PHP Extension versions #12

Check PHP Extension versions

Check PHP Extension versions #12

Workflow file for this run

name: Check PHP Extension versions
on:
workflow_dispatch:
jobs:
check:
runs-on: windows-2022
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Run extension check
shell: pwsh
run: |
$j = Get-Content "extension/BuildPhpExtension/config/matrix.json" | ConvertFrom-Json
function Normalize-Version($v) {
if (-not $v -or $v -notmatch '^\d') { return $null }
$v = $v -replace '[^0-9\.]', ''
try { return [version]$v } catch { return $null }
}
function Get-GitHubLatestTag($repoUrl) {
if ($repoUrl -match 'github\.com/([^/]+)/([^/]+)') {
$owner = $matches[1]
$repo = $matches[2] -replace '\.git$', ''
$apiUrl = "https://api.github.com/repos/$owner/$repo/releases/latest"
try {
$resp = Invoke-RestMethod -Headers @{ "User-Agent"="gh-actions" } -Uri $apiUrl -ErrorAction Stop
if (-not $resp.tag_name) {
return @{ tag=$null; url=$apiUrl }
}
return @{ tag=$resp.tag_name; url=$apiUrl }
} catch {
return @{ tag=$null; url=$apiUrl }
}
} else {
return @{ tag=$null; url=$null }
}
}
foreach ($ext in $j.PSObject.Properties.Name) {
$matrixEntry = $j.$ext
$matrixVersions = $matrixEntry.ver.PSObject.Properties.Value `
| ForEach-Object { Normalize-Version $_ } `
| Where-Object { $_ }
if (-not $matrixVersions) { continue }
$matrixMax = ($matrixVersions | Sort-Object -Descending)[0]
$sourceUrl = $matrixEntry.source
$checkUrl = ""
try {
$latestVer = $null
if ($sourceUrl -and $sourceUrl -match 'github\.com') {
$tagInfo = Get-GitHubLatestTag $sourceUrl
$checkUrl = $tagInfo.url
if (-not $tagInfo.tag) { continue } # нет релизов → пропускаем
$latestVer = Normalize-Version $tagInfo.tag
}
else {
if ($ext -eq 'ddtrace') {
$peclName = 'datadog_trace'
} else {
$peclName = $ext
}
$checkUrl = "https://pecl.php.net/rest/r/$peclName/latest.txt"
$peclRaw = Invoke-RestMethod $checkUrl
if ($peclRaw -match 'RC|beta|alpha') { continue }
$latestVer = Normalize-Version $peclRaw
}
if ($latestVer -and $latestVer -gt $matrixMax) {
Write-Host "🔄 ${ext} => матрица $matrixMax < latest $latestVer"
Write-Host " URL: $checkUrl"
}
} catch {
Write-Warning "⚠️ ${ext} ошибка при проверке"
if ($checkUrl) {
Write-Host " URL: $checkUrl"
}
}
}