Skip to content

Commit 70a9bcd

Browse files
committed
fixup! wip: windows-release
1 parent 282c5e7 commit 70a9bcd

4 files changed

Lines changed: 91 additions & 17 deletions

File tree

.github/workflows/install.ps1

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ if (-not (Test-Path 'C:\php')) {
77
# PHP SDK
88
$bname = "php-sdk-$env:BIN_SDK_VER.zip"
99
if (-not (Test-Path C:\php\$bname)) {
10-
echo "Download: https://github.com/php/php-sdk-binary-tools/archive/$bname"
11-
Invoke-WebRequest "https://github.com/php/php-sdk-binary-tools/archive/$bname" -OutFile "C:\php\$bname"
10+
throw "no such file: $bname"
11+
# echo "Download: https://github.com/php/php-sdk-binary-tools/archive/$bname"
12+
# Invoke-WebRequest "https://github.com/php/php-sdk-binary-tools/archive/$bname" -OutFile "C:\php\$bname"
1213
}
1314
$dname0 = "php-sdk-binary-tools-php-sdk-$env:BIN_SDK_VER"
1415
$dname1 = "php-sdk-$env:BIN_SDK_VER"
@@ -18,7 +19,9 @@ if (-not (Test-Path "C:\php\$dname1")) {
1819
}
1920

2021
# PHP releases
21-
Invoke-WebRequest "https://windows.php.net/downloads/releases/releases.json" -OutFile "C:\php\releases.json"
22+
if (-not (Test-Path C:\php\releases.json)) {
23+
Invoke-WebRequest "https://windows.php.net/downloads/releases/releases.json" -OutFile "C:\php\releases.json"
24+
}
2225
$php_version = (Get-Content -Path "C:\php\releases.json" | ConvertFrom-Json | ForEach-Object {
2326
if ($_."$env:PHP_VER") {
2427
return $_."$env:PHP_VER".version
@@ -34,13 +37,14 @@ if ('nts' -eq $env:TS) {
3437
}
3538
$bname = "php-devel-pack-$php_version$ts_part-Win32-$env:VS-$env:ARCH.zip"
3639
if (-not (Test-Path "C:\php\$bname")) {
37-
try {
38-
echo "Download: https://windows.php.net/downloads/releases/$bname"
39-
Invoke-WebRequest "https://windows.php.net/downloads/releases/$bname" -OutFile "C:\php\$bname"
40-
} catch [System.Net.WebException] {
41-
echo "Downlaod: https://windows.php.net/downloads/releases/archives/$bname"
42-
Invoke-WebRequest "https://windows.php.net/downloads/releases/archives/$bname" -OutFile "C:\php\$bname"
43-
}
40+
throw "no such file: $bname"
41+
# try {
42+
# echo "Download: https://windows.php.net/downloads/releases/$bname"
43+
# Invoke-WebRequest "https://windows.php.net/downloads/releases/$bname" -OutFile "C:\php\$bname"
44+
# } catch [System.Net.WebException] {
45+
# echo "Downlaod: https://windows.php.net/downloads/releases/archives/$bname"
46+
# Invoke-WebRequest "https://windows.php.net/downloads/releases/archives/$bname" -OutFile "C:\php\$bname"
47+
# }
4448
}
4549
$dname = "php-$php_version-devel-$env:VS-$env:ARCH"
4650
if (-not (Test-Path "C:\php\devel")) {
@@ -57,13 +61,14 @@ if (-not (Test-Path "C:\php\devel")) {
5761
# PHP binary: "C:\php\bin"
5862
$bname = "php-$php_version$ts_part-Win32-$env:VS-$env:ARCH.zip"
5963
if (-not (Test-Path "C:\php\$bname")) {
60-
try {
61-
echo "Download: https://windows.php.net/downloads/releases/$bname"
62-
Invoke-WebRequest "https://windows.php.net/downloads/releases/$bname" -OutFile "C:\php\$bname"
63-
} catch [System.Net.WebException] {
64-
echo "Download: https://windows.php.net/downloads/releases/archives/$bname"
65-
Invoke-WebRequest "https://windows.php.net/downloads/releases/archives/$bname" -OutFile "C:\php\$bname"
66-
}
64+
throw "no such file: $bname"
65+
# try {
66+
# echo "Download: https://windows.php.net/downloads/releases/$bname"
67+
# Invoke-WebRequest "https://windows.php.net/downloads/releases/$bname" -OutFile "C:\php\$bname"
68+
# } catch [System.Net.WebException] {
69+
# echo "Download: https://windows.php.net/downloads/releases/archives/$bname"
70+
# Invoke-WebRequest "https://windows.php.net/downloads/releases/archives/$bname" -OutFile "C:\php\$bname"
71+
# }
6772
}
6873
if (-not (Test-Path "C:\php\bin")) {
6974
Expand-Archive "C:\php\$bname" "C:\php\bin"

.github/workflows/prepare.ps1

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
$ErrorActionPreference = "Stop"
2+
3+
if (-not (Test-Path 'C:\php')) {
4+
[void](New-Item 'C:\php' -ItemType 'directory')
5+
}
6+
7+
# PHP SDK
8+
$bname = "php-sdk-$env:BIN_SDK_VER.zip"
9+
if (-not (Test-Path C:\php\$bname)) {
10+
echo "Download: https://github.com/php/php-sdk-binary-tools/archive/$bname"
11+
Invoke-WebRequest "https://github.com/php/php-sdk-binary-tools/archive/$bname" -OutFile "C:\php\$bname"
12+
}
13+
14+
# PHP releases
15+
if (-not (Test-Path C:\php\$bname)) {
16+
echo "Download: https://windows.php.net/downloads/releases/releases.json"
17+
Invoke-WebRequest "https://windows.php.net/downloads/releases/releases.json" -OutFile "C:\php\releases.json"
18+
}
19+
$php_version = (Get-Content -Path "C:\php\releases.json" | ConvertFrom-Json | ForEach-Object {
20+
if ($_."$env:PHP_VER") {
21+
return $_."$env:PHP_VER".version
22+
} else {
23+
return "$env:PHP_VER"
24+
}
25+
})
26+
27+
# PHP devel pack
28+
$ts_part = ''
29+
if ('nts' -eq $env:TS) {
30+
$ts_part = '-nts'
31+
}
32+
$bname = "php-devel-pack-$php_version$ts_part-Win32-$env:VS-$env:ARCH.zip"
33+
if (-not (Test-Path "C:\php\$bname")) {
34+
try {
35+
echo "Download: https://windows.php.net/downloads/releases/$bname"
36+
Invoke-WebRequest "https://windows.php.net/downloads/releases/$bname" -OutFile "C:\php\$bname"
37+
} catch [System.Net.WebException] {
38+
echo "Downlaod: https://windows.php.net/downloads/releases/archives/$bname"
39+
Invoke-WebRequest "https://windows.php.net/downloads/releases/archives/$bname" -OutFile "C:\php\$bname"
40+
}
41+
}
42+
43+
# PHP binary
44+
$bname = "php-$php_version$ts_part-Win32-$env:VS-$env:ARCH.zip"
45+
if (-not (Test-Path "C:\php\$bname")) {
46+
try {
47+
echo "Download: https://windows.php.net/downloads/releases/$bname"
48+
Invoke-WebRequest "https://windows.php.net/downloads/releases/$bname" -OutFile "C:\php\$bname"
49+
} catch [System.Net.WebException] {
50+
echo "Download: https://windows.php.net/downloads/releases/archives/$bname"
51+
Invoke-WebRequest "https://windows.php.net/downloads/releases/archives/$bname" -OutFile "C:\php\$bname"
52+
}
53+
}

.github/workflows/windows-release.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,14 @@ jobs:
2222
ARCH: ${{ matrix.arch }}
2323
TS: ${{ matrix.ts }}
2424
steps:
25+
- uses: actions/cache@v4
26+
with:
27+
path: |
28+
C:\php\php-*.zip
29+
key: ${{ runner.os }}-php
30+
- name: Download dependecies files
31+
run: .\.github\workflows\prepare.ps1
32+
shell: powershell
2533
- name: Checkout repository
2634
uses: actions/checkout@v4
2735
with:

.github/workflows/windows.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,14 @@ jobs:
4646
TS: ${{ matrix.ts }}
4747

4848
steps:
49+
- uses: actions/cache@v4
50+
with:
51+
path: |
52+
C:\php\php-*.zip
53+
key: ${{ runner.os }}-php
54+
- name: Download dependecies files
55+
run: .\.github\workflows\prepare.ps1
56+
4957
- name: Checkout repository
5058
uses: actions/checkout@v4
5159

0 commit comments

Comments
 (0)