ci: fix Windows asset upload (#2245)

This commit is contained in:
Kévin Dunglas
2026-03-07 19:44:08 +01:00
committed by GitHub
parent 74e8195dc8
commit b570e0f8ba
4 changed files with 38 additions and 39 deletions

View File

@@ -8,6 +8,8 @@ on:
- "docs/**"
- "README.md"
- "CONTRIBUTING.md"
- "install.ps1"
- "install.sh"
permissions: {}
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}

View File

@@ -40,8 +40,22 @@ env:
jobs:
build:
permissions:
contents: write
runs-on: windows-latest
steps:
- name: Determine ref
run: |
$ref = $env:REF
if (-not $ref -and $env:GITHUB_EVENT_NAME -eq "schedule") {
$ref = (gh release view --repo php/frankenphp --json tagName --jq '.tagName')
}
"REF=$ref" >> $env:GITHUB_ENV
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REF: ${{ (github.ref_type == 'tag' && github.ref_name) || (github.event_name == 'workflow_dispatch' && inputs.version) || '' }}
- name: Configure Git
run: |
git config --global core.autocrlf false
@@ -50,15 +64,22 @@ jobs:
- name: Checkout Code
uses: actions/checkout@v6
with:
ref: ${{ env.REF || '' }}
path: frankenphp
persist-credentials: false
- name: Set FRANKENPHP_VERSION
run: |
$ref = $env:REF
if ($env:GITHUB_REF_TYPE -eq "tag") {
$frankenphpVersion = $env:GITHUB_REF_NAME.Substring(1)
} elseif ($env:GITHUB_EVENT_NAME -eq "schedule") {
$frankenphpVersion = $env:GITHUB_REF
} elseif ($ref) {
if ($ref.StartsWith("v")) {
$frankenphpVersion = $ref.Substring(1)
} else {
$frankenphpVersion = $ref
}
} else {
$frankenphpVersion = $env:GITHUB_SHA
}
@@ -72,7 +93,7 @@ jobs:
cache-dependency-path: |
frankenphp/go.sum
frankenphp/caddy/go.sum
cache: ${{ github.event_name != 'release' }}
cache: ${{ !startsWith(github.ref, 'refs/tags/') }}
check-latest: true
- name: Install Vcpkg Libraries
@@ -108,7 +129,7 @@ jobs:
$phpZip = "php-$version-Win32-vs17-x64.zip"
$develZip = "php-devel-pack-$version-Win32-vs17-x64.zip"
$dirName = "frankenphp-$env:FRANKENPHP_VERSION-php-$version-Win32-vs17-x64"
$dirName = "frankenphp-windows-x86_64"
"DIR_NAME=$dirName" >> $env:GITHUB_ENV
@@ -185,7 +206,7 @@ jobs:
Copy-Item frankenphp\vcpkg_installed\x64-windows\bin\pthreadVC3.dll $env:DIR_NAME
- name: Upload Artifact
if: github.event_name != 'release'
if: ${{ !env.REF }}
uses: actions/upload-artifact@v6
with:
name: ${{ env.DIR_NAME }}
@@ -193,15 +214,14 @@ jobs:
if-no-files-found: error
- name: Zip Release Artifact
if: github.event_name == 'release'
if: ${{ env.REF }}
run: Compress-Archive -Path "$env:DIR_NAME\*" -DestinationPath "$env:DIR_NAME.zip"
- name: Upload Release Asset
if: github.event_name == 'release'
run: gh release upload $env:GITHUB_EVENT_RELEASE_TAG_NAME "$env:DIR_NAME.zip" --clobber
if: ${{ env.REF }}
run: gh release upload "$env:REF" "$env:DIR_NAME.zip" --repo php/frankenphp --clobber
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_EVENT_RELEASE_TAG_NAME: ${{ github.event.release.tag_name }}
- name: Run Tests
run: |

View File

@@ -20,29 +20,12 @@ if ($env:FRANKENPHP_INSTALL) {
$BinDir = Join-Path $HOME ".frankenphp"
}
Write-Host "Querying latest FrankenPHP release..." -ForegroundColor Cyan
try {
$release = Invoke-RestMethod -Uri "https://api.github.com/repos/php/frankenphp/releases/latest"
} catch {
Write-Host "Could not query GitHub releases: $_" -ForegroundColor Red
exit 1
}
$asset = $release.assets | Where-Object { $_.name -match "Win32-vs17-x64\.zip$" } | Select-Object -First 1
if (-not $asset) {
Write-Host "Could not find a Windows release asset." -ForegroundColor Red
Write-Host "Check https://github.com/php/frankenphp/releases for available downloads." -ForegroundColor Red
exit 1
}
Write-Host "Downloading $($asset.name)..." -ForegroundColor Cyan
Write-Host "Downloading FrankenPHP for Windows (x64)..." -ForegroundColor Cyan
$tmpZip = Join-Path $env:TEMP "frankenphp-windows-$PID.zip"
try {
Invoke-WebRequest -Uri $asset.browser_download_url -OutFile $tmpZip
Invoke-WebRequest -Uri "https://github.com/php/frankenphp/releases/latest/download/frankenphp-windows-x86_64.zip" -OutFile $tmpZip
} catch {
Write-Host "Download failed: $_" -ForegroundColor Red
exit 1

View File

@@ -132,20 +132,14 @@ CYGWIN_NT* | MSYS_NT* | MINGW*)
exit 1
fi
WIN_ASSET=$(curl -s https://api.github.com/repos/php/frankenphp/releases/latest |
grep -o '"name": *"frankenphp-[^"]*-Win32-vs17-x64\.zip"' | head -1 |
sed 's/"name": *"//;s/"//')
if [ -z "${WIN_ASSET}" ]; then
echo "❗ Could not find a Windows release asset"
echo "❗ Check https://github.com/php/frankenphp/releases for available downloads"
exit 1
fi
echo "📦 Downloading ${bold}FrankenPHP${normal} for Windows (x64):"
TMPZIP="/tmp/frankenphp-windows-$$.zip"
curl -L --progress-bar "https://github.com/php/frankenphp/releases/latest/download/${WIN_ASSET}" -o "${TMPZIP}"
if ! curl -f -L --progress-bar "https://github.com/php/frankenphp/releases/latest/download/frankenphp-windows-x86_64.zip" -o "${TMPZIP}"; then
echo "❗ Failed to download FrankenPHP for Windows. Please check your internet connection or download it manually from:"
echo " https://github.com/php/frankenphp/releases/latest"
exit 1
fi
echo "📂 Extracting to ${italic}${BIN_DIR}${normal}..."
if command -v unzip >/dev/null 2>&1; then