Skip to content

Commit b84ebd1

Browse files
authored
Update pecl.yml
1 parent 097838b commit b84ebd1

File tree

1 file changed

+77
-70
lines changed

1 file changed

+77
-70
lines changed

.github/workflows/pecl.yml

Lines changed: 77 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -123,90 +123,97 @@ jobs:
123123
auto-detect-args: true
124124
auto-detect-libs: true
125125
no-debug-symbols-ddtrace: true
126-
127-
pecl-release:
128-
runs-on: ubuntu-latest
129-
needs: [get-extension-matrix, extension]
130-
strategy:
131-
matrix: ${{fromJson(needs.get-extension-matrix.outputs.matrix)}}
132-
steps:
133-
- name: Create or Update PECL Release
126+
- name: Upload to release immediately
127+
shell: pwsh
134128
env:
135129
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
136130
run: |
137-
extension_url="${{ inputs.extension-url }}"
138-
extension_original=$(basename "$extension_url" | tr '[:upper:]' '[:lower:]')
139-
extension="$extension_original"
131+
$extensionUrl = "${{ inputs.extension-url }}"
132+
$extensionOriginal = (Split-Path $extensionUrl -Leaf).ToLower()
133+
$extension = $extensionOriginal
140134
141135
# Replace extension names for release
142-
case "$extension_original" in
143-
"base58-php-ext") extension="base58" ;;
144-
"dd-trace-php") extension="ddtrace" ;;
145-
"msgpack-php") extension="msgpack" ;;
146-
"php-firebird") extension="interbase" ;;
147-
"php-ext-lz4") extension="lz4" ;;
148-
"php-memcached") extension="memcached" ;;
149-
"pecl-database-oci8") extension="oci8" ;;
150-
"pecl-database-pdo_oci") extension="pdo_oci" ;;
151-
"pecl-text-ssdeep") extension="ssdeep" ;;
152-
esac
136+
switch ($extensionOriginal) {
137+
"base58-php-ext" { $extension = "base58" }
138+
"dd-trace-php" { $extension = "ddtrace" }
139+
"msgpack-php" { $extension = "msgpack" }
140+
"php-firebird" { $extension = "interbase" }
141+
"php-ext-lz4" { $extension = "lz4" }
142+
"php-memcached" { $extension = "memcached" }
143+
"pecl-database-oci8" { $extension = "oci8" }
144+
"pecl-database-pdo_oci" { $extension = "pdo_oci" }
145+
"pecl-text-ssdeep" { $extension = "ssdeep" }
146+
}
153147
154-
php_version="${{ matrix.php-version }}"
155-
arch="${{ matrix.arch }}"
156-
ts="${{ matrix.ts }}"
157-
ref="${{ inputs.extension-ref }}"
158-
ref_clean=$(echo "$ref" | sed 's/^v//')
148+
$phpVersion = "${{ matrix.php-version }}"
149+
$arch = "${{ matrix.arch }}"
150+
$ts = "${{ matrix.ts }}"
151+
$ref = "${{ inputs.extension-ref }}"
152+
$refClean = $ref -replace '^v', ''
159153
160-
case "$php_version" in
161-
7.2|7.3|7.4) vs_version="vc15" ;;
162-
8.0|8.1|8.2|8.3) vs_version="vs16" ;;
163-
8.4|8.5) vs_version="vs17" ;;
164-
*) vs_version="vs16" ;; # fallback
165-
esac
154+
$vsVersion = switch ($phpVersion) {
155+
{ $_ -in @("7.2", "7.3", "7.4") } { "vc15" }
156+
{ $_ -in @("8.0", "8.1", "8.2", "8.3") } { "vs16" }
157+
{ $_ -in @("8.4", "8.5") } { "vs17" }
158+
default { "vs16" }
159+
}
166160
167161
# Artifact name uses original extension name and ref with 'v'
168-
artifact_name="php_${extension_original}-${ref}-${php_version}-${ts}-${vs_version}-${arch}.zip"
169-
artifact_name_modern="php_${extension}-${ref}-${php_version}-${ts}-${vs_version}-${arch}.zip"
170-
final_name="${artifact_name}"
162+
$artifactName = "php_${extensionOriginal}-${ref}-${phpVersion}-${ts}-${vsVersion}-${arch}.zip"
163+
$artifactNameModern = "php_${extension}-${ref}-${phpVersion}-${ts}-${vsVersion}-${arch}.zip"
164+
171165
# Release uses new extension name and ref without 'v'
172-
release_tag="${extension}-${ref_clean}"
173-
release_asset_name="php_${extension}-${ref_clean}-${php_version}-${ts}-${vs_version}-${arch}.zip"
166+
$releaseTag = "${extension}-${refClean}"
167+
$releaseAssetName = "php_${extension}-${refClean}-${phpVersion}-${ts}-${vsVersion}-${arch}.zip"
174168
175-
artifact_id=$(gh api repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts \
176-
--jq ".artifacts[] | select(.name==\"${artifact_name}\") | .id")
177-
178-
if [ -z "$artifact_id" ]; then
179-
artifact_id=$(gh api repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts \
180-
--jq ".artifacts[] | select(.name==\"${artifact_name_modern}\") | .id")
181-
final_name="${artifact_name_modern}"
182-
if [ -z "$artifact_id" ]; then
183-
echo "Artifact ${artifact_name} not found"
184-
exit 1
185-
fi
186-
fi
187-
188-
curl -L \
189-
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
190-
-H "Accept: application/vnd.github.v3+json" \
191-
"https://github.com/api/repos/${{ github.repository }}/actions/artifacts/${artifact_id}/zip" \
192-
-o "artifact_wrapper.zip"
193-
194-
unzip "artifact_wrapper.zip"
195-
196-
# Rename the artifact file to the new naming scheme
197-
if [ -f "${final_name}" ]; then
198-
if [ "${final_name}" != "${release_asset_name}" ]; then
199-
mv "${final_name}" "${release_asset_name}"
200-
fi
201-
fi
169+
# Найти собранный ZIP файл с оригинальным или современным именем
170+
$searchPaths = @(".", "C:\b", ".\artifacts", ".\build")
171+
$builtFile = $null
172+
$finalName = $artifactName
173+
174+
foreach ($searchPath in $searchPaths) {
175+
if (Test-Path $searchPath) {
176+
# Ищем файл с оригинальным именем
177+
$foundFile = Get-ChildItem -Path $searchPath -Filter $artifactName -File -ErrorAction SilentlyContinue | Select-Object -First 1
178+
if ($foundFile) {
179+
$builtFile = $foundFile.FullName
180+
$finalName = $artifactName
181+
break
182+
}
183+
184+
# Ищем файл с современным именем
185+
$foundFile = Get-ChildItem -Path $searchPath -Filter $artifactNameModern -File -ErrorAction SilentlyContinue | Select-Object -First 1
186+
if ($foundFile) {
187+
$builtFile = $foundFile.FullName
188+
$finalName = $artifactNameModern
189+
break
190+
}
191+
}
192+
}
193+
194+
if ($builtFile -and (Test-Path $builtFile)) {
195+
Write-Host "Found built file: $builtFile"
196+
197+
# Rename the artifact file to the new naming scheme if needed
198+
if ($finalName -ne $releaseAssetName) {
199+
Copy-Item $builtFile $releaseAssetName
200+
} else {
201+
$releaseAssetName = $builtFile
202+
}
203+
204+
Write-Host "Uploading $releaseAssetName to release $releaseTag"
205+
gh release upload $releaseTag $releaseAssetName -R ${{ github.repository }} --clobber
206+
} else {
207+
Write-Host "No built ZIP file found! Searched for: $artifactName, $artifactNameModern"
208+
Write-Host "Current directory contents:"
209+
Get-ChildItem -Recurse -Filter "*.zip" -ErrorAction SilentlyContinue | ForEach-Object { Write-Host $_.FullName }
210+
exit 1
211+
}
202212
203-
gh release upload "${release_tag}" "${release_asset_name}" \
204-
-R ${{ github.repository }} --clobber
205-
206213
cleanup-artifacts:
207214
runs-on: ubuntu-latest
208215
if: success()
209-
needs: [pecl-release]
216+
needs: [extension]
210217
steps:
211218
- name: Cleanup artifacts after successful release
212219
env:
@@ -224,7 +231,7 @@ jobs:
224231
cleanup-release:
225232
runs-on: ubuntu-latest
226233
if: failure()
227-
needs: [get-extension-matrix, extension, pecl-release]
234+
needs: [get-extension-matrix, extension]
228235
steps:
229236
- name: Checkout repository
230237
uses: actions/checkout@v4

0 commit comments

Comments
 (0)