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/**" - "docs/**"
- "README.md" - "README.md"
- "CONTRIBUTING.md" - "CONTRIBUTING.md"
- "install.ps1"
- "install.sh"
permissions: {} permissions: {}
concurrency: concurrency:
group: ${{ github.workflow }}-${{ github.ref }} group: ${{ github.workflow }}-${{ github.ref }}

View File

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

View File

@@ -20,29 +20,12 @@ if ($env:FRANKENPHP_INSTALL) {
$BinDir = Join-Path $HOME ".frankenphp" $BinDir = Join-Path $HOME ".frankenphp"
} }
Write-Host "Querying latest FrankenPHP release..." -ForegroundColor Cyan Write-Host "Downloading FrankenPHP for Windows (x64)..." -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
$tmpZip = Join-Path $env:TEMP "frankenphp-windows-$PID.zip" $tmpZip = Join-Path $env:TEMP "frankenphp-windows-$PID.zip"
try { 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 { } catch {
Write-Host "Download failed: $_" -ForegroundColor Red Write-Host "Download failed: $_" -ForegroundColor Red
exit 1 exit 1

View File

@@ -132,20 +132,14 @@ CYGWIN_NT* | MSYS_NT* | MINGW*)
exit 1 exit 1
fi 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):" echo "📦 Downloading ${bold}FrankenPHP${normal} for Windows (x64):"
TMPZIP="/tmp/frankenphp-windows-$$.zip" 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}..." echo "📂 Extracting to ${italic}${BIN_DIR}${normal}..."
if command -v unzip >/dev/null 2>&1; then if command -v unzip >/dev/null 2>&1; then