Skip to content

Commit b570e0f

Browse files
authored
ci: fix Windows asset upload (#2245)
1 parent 74e8195 commit b570e0f

File tree

4 files changed

+38
-39
lines changed

4 files changed

+38
-39
lines changed

β€Ž.github/workflows/docs.yamlβ€Ž

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ on:
88
- "docs/**"
99
- "README.md"
1010
- "CONTRIBUTING.md"
11+
- "install.ps1"
12+
- "install.sh"
1113
permissions: {}
1214
concurrency:
1315
group: ${{ github.workflow }}-${{ github.ref }}

β€Ž.github/workflows/windows.yamlβ€Ž

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,22 @@ env:
4040

4141
jobs:
4242
build:
43+
permissions:
44+
contents: write
4345
runs-on: windows-latest
4446
steps:
47+
- name: Determine ref
48+
run: |
49+
$ref = $env:REF
50+
if (-not $ref -and $env:GITHUB_EVENT_NAME -eq "schedule") {
51+
$ref = (gh release view --repo php/frankenphp --json tagName --jq '.tagName')
52+
}
53+
54+
"REF=$ref" >> $env:GITHUB_ENV
55+
env:
56+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
57+
REF: ${{ (github.ref_type == 'tag' && github.ref_name) || (github.event_name == 'workflow_dispatch' && inputs.version) || '' }}
58+
4559
- name: Configure Git
4660
run: |
4761
git config --global core.autocrlf false
@@ -50,15 +64,22 @@ jobs:
5064
- name: Checkout Code
5165
uses: actions/checkout@v6
5266
with:
67+
ref: ${{ env.REF || '' }}
5368
path: frankenphp
5469
persist-credentials: false
5570

5671
- name: Set FRANKENPHP_VERSION
5772
run: |
73+
$ref = $env:REF
74+
5875
if ($env:GITHUB_REF_TYPE -eq "tag") {
5976
$frankenphpVersion = $env:GITHUB_REF_NAME.Substring(1)
60-
} elseif ($env:GITHUB_EVENT_NAME -eq "schedule") {
61-
$frankenphpVersion = $env:GITHUB_REF
77+
} elseif ($ref) {
78+
if ($ref.StartsWith("v")) {
79+
$frankenphpVersion = $ref.Substring(1)
80+
} else {
81+
$frankenphpVersion = $ref
82+
}
6283
} else {
6384
$frankenphpVersion = $env:GITHUB_SHA
6485
}
@@ -72,7 +93,7 @@ jobs:
7293
cache-dependency-path: |
7394
frankenphp/go.sum
7495
frankenphp/caddy/go.sum
75-
cache: ${{ github.event_name != 'release' }}
96+
cache: ${{ !startsWith(github.ref, 'refs/tags/') }}
7697
check-latest: true
7798

7899
- name: Install Vcpkg Libraries
@@ -108,7 +129,7 @@ jobs:
108129
$phpZip = "php-$version-Win32-vs17-x64.zip"
109130
$develZip = "php-devel-pack-$version-Win32-vs17-x64.zip"
110131
111-
$dirName = "frankenphp-$env:FRANKENPHP_VERSION-php-$version-Win32-vs17-x64"
132+
$dirName = "frankenphp-windows-x86_64"
112133
113134
"DIR_NAME=$dirName" >> $env:GITHUB_ENV
114135
@@ -185,23 +206,22 @@ jobs:
185206
Copy-Item frankenphp\vcpkg_installed\x64-windows\bin\pthreadVC3.dll $env:DIR_NAME
186207
187208
- name: Upload Artifact
188-
if: github.event_name != 'release'
209+
if: ${{ !env.REF }}
189210
uses: actions/upload-artifact@v6
190211
with:
191212
name: ${{ env.DIR_NAME }}
192213
path: ${{ env.DIR_NAME }}
193214
if-no-files-found: error
194215

195216
- name: Zip Release Artifact
196-
if: github.event_name == 'release'
217+
if: ${{ env.REF }}
197218
run: Compress-Archive -Path "$env:DIR_NAME\*" -DestinationPath "$env:DIR_NAME.zip"
198219

199220
- name: Upload Release Asset
200-
if: github.event_name == 'release'
201-
run: gh release upload $env:GITHUB_EVENT_RELEASE_TAG_NAME "$env:DIR_NAME.zip" --clobber
221+
if: ${{ env.REF }}
222+
run: gh release upload "$env:REF" "$env:DIR_NAME.zip" --repo php/frankenphp --clobber
202223
env:
203224
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
204-
GITHUB_EVENT_RELEASE_TAG_NAME: ${{ github.event.release.tag_name }}
205225

206226
- name: Run Tests
207227
run: |

β€Žinstall.ps1β€Ž

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -20,29 +20,12 @@ if ($env:FRANKENPHP_INSTALL) {
2020
$BinDir = Join-Path $HOME ".frankenphp"
2121
}
2222

23-
Write-Host "Querying latest FrankenPHP release..." -ForegroundColor Cyan
24-
25-
try {
26-
$release = Invoke-RestMethod -Uri "https://api.github.com/repos/php/frankenphp/releases/latest"
27-
} catch {
28-
Write-Host "Could not query GitHub releases: $_" -ForegroundColor Red
29-
exit 1
30-
}
31-
32-
$asset = $release.assets | Where-Object { $_.name -match "Win32-vs17-x64\.zip$" } | Select-Object -First 1
33-
34-
if (-not $asset) {
35-
Write-Host "Could not find a Windows release asset." -ForegroundColor Red
36-
Write-Host "Check https://github.com/php/frankenphp/releases for available downloads." -ForegroundColor Red
37-
exit 1
38-
}
39-
40-
Write-Host "Downloading $($asset.name)..." -ForegroundColor Cyan
23+
Write-Host "Downloading FrankenPHP for Windows (x64)..." -ForegroundColor Cyan
4124

4225
$tmpZip = Join-Path $env:TEMP "frankenphp-windows-$PID.zip"
4326

4427
try {
45-
Invoke-WebRequest -Uri $asset.browser_download_url -OutFile $tmpZip
28+
Invoke-WebRequest -Uri "https://github.com/php/frankenphp/releases/latest/download/frankenphp-windows-x86_64.zip" -OutFile $tmpZip
4629
} catch {
4730
Write-Host "Download failed: $_" -ForegroundColor Red
4831
exit 1

β€Žinstall.shβ€Ž

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -132,20 +132,14 @@ CYGWIN_NT* | MSYS_NT* | MINGW*)
132132
exit 1
133133
fi
134134

135-
WIN_ASSET=$(curl -s https://api.github.com/repos/php/frankenphp/releases/latest |
136-
grep -o '"name": *"frankenphp-[^"]*-Win32-vs17-x64\.zip"' | head -1 |
137-
sed 's/"name": *"//;s/"//')
138-
139-
if [ -z "${WIN_ASSET}" ]; then
140-
echo "❗ Could not find a Windows release asset"
141-
echo "❗ Check https://github.com/php/frankenphp/releases for available downloads"
142-
exit 1
143-
fi
144-
145135
echo "πŸ“¦ Downloading ${bold}FrankenPHP${normal} for Windows (x64):"
146136

147137
TMPZIP="/tmp/frankenphp-windows-$$.zip"
148-
curl -L --progress-bar "https://github.com/php/frankenphp/releases/latest/download/${WIN_ASSET}" -o "${TMPZIP}"
138+
if ! curl -f -L --progress-bar "https://github.com/php/frankenphp/releases/latest/download/frankenphp-windows-x86_64.zip" -o "${TMPZIP}"; then
139+
echo "❗ Failed to download FrankenPHP for Windows. Please check your internet connection or download it manually from:"
140+
echo " https://github.com/php/frankenphp/releases/latest"
141+
exit 1
142+
fi
149143

150144
echo "πŸ“‚ Extracting to ${italic}${BIN_DIR}${normal}..."
151145
if command -v unzip >/dev/null 2>&1; then

0 commit comments

Comments
Β (0)