-
Notifications
You must be signed in to change notification settings - Fork 1
486 lines (435 loc) · 21.9 KB
/
Copy pathbuild.yml
File metadata and controls
486 lines (435 loc) · 21.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
name: Build & Release TypePHP Webman
on:
push:
tags:
- 'v*'
workflow_dispatch:
inputs:
platform:
description: Build target
type: choice
required: true
default: all
options:
- all
- linux
- static
- windows
permissions:
contents: write
env:
COMPOSER_NO_INTERACTION: 1
COMPOSER_PROCESS_TIMEOUT: 0
jobs:
select-platform:
name: Select build platform
runs-on: ubuntu-22.04
outputs:
matrix: ${{ steps.matrix.outputs.matrix }}
steps:
- name: Generate build matrix
id: matrix
shell: bash
env:
REQUESTED_PLATFORM: ${{ inputs.platform }}
TAG_NAME: ${{ github.ref_name }}
run: |
PLATFORM="$REQUESTED_PLATFORM"
if [ -z "$PLATFORM" ]; then
if [[ "$TAG_NAME" == *"-linux"* ]]; then
PLATFORM="linux"
elif [[ "$TAG_NAME" == *"-windows"* ]]; then
PLATFORM="windows"
else
PLATFORM="all"
fi
fi
echo "Target platform selected: $PLATFORM"
case "$PLATFORM" in
linux)
matrix='{"include":[{"os":"ubuntu-22.04","platform":"linux-x64","build_type":"dynamic","archive_name":"typephp-webman-linux-x64.tar.gz"}]}'
;;
static)
matrix='{"include":[{"os":"ubuntu-22.04","platform":"linux-x64-static","build_type":"static","archive_name":"typephp-webman-linux-x64-static.tar.gz"}]}'
;;
windows)
matrix='{"include":[{"os":"windows-latest","platform":"windows-x64","build_type":"dynamic","archive_name":"typephp-webman-windows-x64.zip"}]}'
;;
all|*)
matrix='{"include":[{"os":"ubuntu-22.04","platform":"linux-x64","build_type":"dynamic","archive_name":"typephp-webman-linux-x64.tar.gz"},{"os":"ubuntu-22.04","platform":"linux-x64-static","build_type":"static","archive_name":"typephp-webman-linux-x64-static.tar.gz"},{"os":"windows-latest","platform":"windows-x64","build_type":"dynamic","archive_name":"typephp-webman-windows-x64.zip"}]}'
;;
esac
echo "matrix=$matrix" >> "$GITHUB_OUTPUT"
build:
needs: select-platform
name: Build ${{ matrix.platform }} (${{ matrix.build_type }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix: ${{ fromJSON(needs.select-platform.outputs.matrix) }}
env:
PHPX_HOME: ${{ github.workspace }}/vendor/swoole/phpx
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Load PHP Extensions List
id: ext
shell: bash
run: |
if [ "${{ runner.os }}" = "Linux" ] && [ -f "extensions.txt" ]; then
EXT_LIST=$(grep -v '^[[:space:]]*#' extensions.txt | grep -v '^[[:space:]]*$' | tr '\r\n' ',' | sed 's/,,*/,/g; s/^,//; s/,$//')
echo "Loaded Linux extensions: $EXT_LIST"
echo "list=$EXT_LIST" >> "$GITHUB_OUTPUT"
else
echo "list=zip" >> "$GITHUB_OUTPUT"
fi
# ---------------- Setup PHP 8.4 (参考官方配置 ZTS 与 embed 支持) ----------------
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.4'
extensions: ${{ steps.ext.outputs.list }}
coverage: none
ini-values: precision=17, memory_limit=4G, error_reporting=E_ERROR|E_WARNING, display_errors=1, display_startup_errors=1, log_errors=0
tools: composer:v2
env:
fail-fast: true
phpts: ts
update: true
# ---------------- Linux 构建环境准备 (官方原生依赖) ----------------
- name: Install Linux native build dependencies
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install --yes build-essential cmake libgmp-dev libmpfr-dev pkg-config python3-dev patchelf libevent-dev
- name: Install Clang and Musl toolchain (Static Build)
if: matrix.build_type == 'static'
run: |
sudo apt-get install --yes clang lld musl-tools
- name: Patch php_hash.h for C++ compatibility
if: runner.os == 'Linux'
shell: bash
run: |
PHP_INC="$(php-config --include-dir 2>/dev/null || echo '')"
echo "PHP include dir: $PHP_INC"
if [ -n "$PHP_INC" ]; then
sudo find "$PHP_INC" /usr/include -name "php_hash.h" -exec sed -i 's/static inline const php_hash_ops\* php_hash_fetch_ops/static inline const struct _php_hash_ops\* php_hash_fetch_ops/g' {} + 2>/dev/null || true
fi
- name: Configure Linux ZTS PHP embed library
if: runner.os == 'Linux'
shell: bash
run: |
php_home="$(php-config --prefix)"
embed_library="${php_home}/lib/libphp.so"
test -x "${php_home}/bin/php-config"
test -f "${embed_library}"
echo "PHP_HOME=${php_home}" >> "${GITHUB_ENV}"
echo "Using ZTS PHP $(php-config --version) embed library: ${embed_library}"
# ---------------- Windows 构建环境准备 ----------------
- name: Setup MSVC Toolchain
if: runner.os == 'Windows'
uses: ilammy/msvc-dev-cmd@v1
- name: Restore Windows GMP and MPFR cache
if: runner.os == 'Windows'
id: cache-gmp-mpfr
uses: actions/cache/restore@v4
with:
path: ${{ runner.temp }}\typephp-cache\vcpkg-x64-windows
key: windows-2022-msvc-vcpkg-gmp-mpfr-x64-v1
- name: Install Windows GMP and MPFR dependencies
if: runner.os == 'Windows' && steps.cache-gmp-mpfr.outputs.cache-hit != 'true'
shell: powershell
run: |
if (-not $env:VCPKG_INSTALLATION_ROOT) {
throw "[CI] VCPKG_INSTALLATION_ROOT is not set on windows-latest"
}
$vcpkg = Join-Path $env:VCPKG_INSTALLATION_ROOT "vcpkg.exe"
if (-not (Test-Path $vcpkg)) {
throw "[CI] vcpkg executable not found: $vcpkg"
}
$triplet = "x64-windows"
& $vcpkg install gmp mpfr --triplet=$triplet --clean-after-build
if ($LASTEXITCODE -ne 0) {
throw "[CI] vcpkg failed to install GMP/MPFR (exit code $LASTEXITCODE)"
}
$nativeRoot = Join-Path $env:VCPKG_INSTALLATION_ROOT "installed\$triplet"
$cacheRoot = Join-Path $env:RUNNER_TEMP "typephp-cache\vcpkg-x64-windows"
New-Item -ItemType Directory -Force -Path "$cacheRoot\include", "$cacheRoot\lib", "$cacheRoot\bin" | Out-Null
$requiredFiles = @(
(Join-Path $nativeRoot "include\gmp.h"),
(Join-Path $nativeRoot "include\mpfr.h"),
(Join-Path $nativeRoot "lib\gmp.lib"),
(Join-Path $nativeRoot "lib\gmpxx.lib"),
(Join-Path $nativeRoot "lib\mpfr.lib")
)
$missing = $requiredFiles | Where-Object { -not (Test-Path $_) }
if ($missing) {
Write-Host "[CI] vcpkg GMP/MPFR root: $nativeRoot"
Get-ChildItem (Join-Path $nativeRoot "include") -ErrorAction SilentlyContinue | Select-Object Name
Get-ChildItem (Join-Path $nativeRoot "lib") -ErrorAction SilentlyContinue | Select-Object Name
throw "[CI] Missing GMP/MPFR files: $($missing -join ', ')"
}
Copy-Item "$nativeRoot\include\*" "$cacheRoot\include" -Recurse -Force
Copy-Item "$nativeRoot\lib\gmp.lib", "$nativeRoot\lib\gmpxx.lib", "$nativeRoot\lib\mpfr.lib" "$cacheRoot\lib" -Force
Copy-Item "$nativeRoot\bin\*.dll" "$cacheRoot\bin" -Force -ErrorAction SilentlyContinue
Write-Host "[CI] Cached GMP/MPFR under: $cacheRoot"
- name: Save Windows GMP and MPFR cache
if: runner.os == 'Windows' && steps.cache-gmp-mpfr.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: ${{ runner.temp }}\typephp-cache\vcpkg-x64-windows
key: ${{ steps.cache-gmp-mpfr.outputs.cache-primary-key }}
- name: Stage Windows GMP and MPFR dependencies
if: runner.os == 'Windows'
shell: powershell
run: |
$cacheRoot = Join-Path $env:RUNNER_TEMP "typephp-cache\vcpkg-x64-windows"
$requiredFiles = @(
(Join-Path $cacheRoot "include\gmp.h"),
(Join-Path $cacheRoot "include\mpfr.h"),
(Join-Path $cacheRoot "lib\gmp.lib"),
(Join-Path $cacheRoot "lib\gmpxx.lib"),
(Join-Path $cacheRoot "lib\mpfr.lib")
)
$missing = $requiredFiles | Where-Object { -not (Test-Path $_) }
if ($missing) {
throw "[CI] GMP/MPFR cache is incomplete: $($missing -join ', ')"
}
"GMP_MPFR_ROOT=$cacheRoot" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8
Write-Host "[CI] Using cached GMP/MPFR root: $cacheRoot"
# ---------------- 安装 Composer 依赖 ----------------
- name: Install Composer Dependencies
run: composer install --prefer-dist --no-progress
# ---------------- Linux 动态版编译与打包 ----------------
- name: Build and Package on Linux (Dynamic)
if: runner.os == 'Linux' && matrix.build_type == 'dynamic'
shell: bash
run: |
chmod +x package.sh start.sh
./package.sh
echo "=== Verify dynamic library dependencies (ldd) ==="
ldd dist/webman-server.bin || true
ldd dist/libphpx.so || true
echo "=== Linux Smoke Test: running dist/start.sh status ==="
./dist/start.sh status || true
tar -czvf ${{ matrix.archive_name }} -C dist .
# ---------------- Linux 全静态版环境与 SDK 组装 ----------------
- name: Restore Full-Static SDK Cache
if: runner.os == 'Linux' && matrix.build_type == 'static'
id: cache-static-sdk
uses: actions/cache/restore@v4
with:
path: vendor/swoole/phpx/full-static/sdk
key: linux-musl-phpx-full-static-sdk-v4
- name: Prepare Musl Full-Static SDK (if cache miss)
if: runner.os == 'Linux' && matrix.build_type == 'static' && steps.cache-static-sdk.outputs.cache-hit != 'true'
shell: bash
run: |
echo "[CI] Assembling musl full-static SDK in Alpine environment..."
chmod +x build-static-sdk.sh
docker run --rm -v "$(pwd):/host" alpine:edge sh /host/build-static-sdk.sh
ls -la vendor/swoole/phpx/full-static/sdk/lib
ls -la vendor/swoole/phpx/full-static/sdk/lib/musl
- name: Save Full-Static SDK Cache
if: runner.os == 'Linux' && matrix.build_type == 'static' && steps.cache-static-sdk.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: vendor/swoole/phpx/full-static/sdk
key: linux-musl-phpx-full-static-sdk-v4
# ---------------- Linux 全静态版编译与打包 ----------------
- name: Build and Package on Linux (Full Static)
if: runner.os == 'Linux' && matrix.build_type == 'static'
shell: bash
run: |
chmod +x package.sh start.sh
./package.sh --full-static
echo "=== Verify Static ELF Linkage ==="
file dist/webman-server
ldd dist/webman-server || true
echo "=== Verify dist contains NO dynamic libraries (.so) ==="
find dist -name "*.so*"
test -z "$(find dist -name "*.so*")"
echo "=== Static Smoke Test: running dist/webman-server status ==="
./dist/webman-server status || true
echo "=== Packaging ${{ matrix.archive_name }} ==="
tar -czvf ${{ matrix.archive_name }} -C dist .
ls -lh ${{ matrix.archive_name }}
# ---------------- Windows 编译与打包 ----------------
- name: Setup PHP Windows Devpack (Headers & Libs for MSVC)
if: runner.os == 'Windows'
shell: powershell
run: |
$phpBin = (Get-Command php.exe).Source
$phpDir = Split-Path -Parent $phpBin
Write-Host "PHP Directory: $phpDir"
$phpVer = (php -r "echo PHP_VERSION;")
Write-Host "[CI] Installed PHP version is $phpVer. Resolving Windows Devpack URL..."
$urls = @(
"https://windows.php.net/downloads/releases/php-devel-pack-$phpVer-Win32-vs17-x64.zip",
"https://windows.php.net/downloads/releases/archives/php-devel-pack-$phpVer-Win32-vs17-x64.zip"
)
$downloaded = $false
foreach ($url in $urls) {
try {
Write-Host "[CI] Trying to download from $url ..."
Invoke-WebRequest -Uri $url -OutFile "$env:TEMP\php-devel-pack.zip" -UseBasicParsing -ErrorAction Stop
$downloaded = $true
Write-Host "[CI] Download successful!"
break
} catch {
Write-Host "[CI] URL not available, trying next..."
}
}
if (-not $downloaded) {
# 兜底抓取 releases 目录里的任一最新 8.4 devpack
Write-Host "[CI] Querying index of windows.php.net/downloads/releases/ ..."
$html = (Invoke-WebRequest -Uri "https://windows.php.net/downloads/releases/" -UseBasicParsing).Content
if ($html -match 'href="([^"]*php-devel-pack-8\.4\.[^"]*-Win32-vs17-x64\.zip)"') {
$fallbackUrl = "https://windows.php.net/downloads/releases/" + $matches[1]
Write-Host "[CI] Found fallback devpack: $fallbackUrl"
Invoke-WebRequest -Uri $fallbackUrl -OutFile "$env:TEMP\php-devel-pack.zip" -UseBasicParsing
$downloaded = $true
}
}
Expand-Archive -Path "$env:TEMP\php-devel-pack.zip" -DestinationPath "$env:TEMP\php-devpack" -Force
$extracted = Get-ChildItem "$env:TEMP\php-devpack" -Directory | Select-Object -First 1
if ($extracted) {
@("$phpDir\SDK\lib", "$phpDir\SDK\include", "$phpDir\dev", "$phpDir\lib", "$phpDir\include") | ForEach-Object {
if (-not (Test-Path $_)) { New-Item -ItemType Directory -Path $_ -Force }
}
Copy-Item -Path "$($extracted.FullName)\lib\*" -Destination "$phpDir\SDK\lib\" -Recurse -Force -ErrorAction SilentlyContinue
Copy-Item -Path "$($extracted.FullName)\include\*" -Destination "$phpDir\SDK\include\" -Recurse -Force -ErrorAction SilentlyContinue
Copy-Item -Path "$($extracted.FullName)\lib\*" -Destination "$phpDir\lib\" -Recurse -Force -ErrorAction SilentlyContinue
Copy-Item -Path "$($extracted.FullName)\lib\*" -Destination "$phpDir\dev\" -Recurse -Force -ErrorAction SilentlyContinue
Copy-Item -Path "$($extracted.FullName)\lib\*" -Destination "$phpDir\" -Force -ErrorAction SilentlyContinue
Copy-Item -Path "$($extracted.FullName)\include\*" -Destination "$phpDir\include\" -Recurse -Force -ErrorAction SilentlyContinue
Write-Host "[CI] Successfully placed .lib files in $phpDir\SDK\lib and $phpDir"
Get-ChildItem "$phpDir\SDK\lib" | Select-Object Name
# PHP 8.4 Devpack's win32/ioutil.h calls _wchmod(), but omits <corecrt_wio.h>.
# Ensure <corecrt_wio.h> is present at the top of ioutil.h.
$ioutilHeader = Join-Path $phpDir "SDK\include\win32\ioutil.h"
if (Test-Path $ioutilHeader) {
$content = Get-Content $ioutilHeader -Raw
if ($content -notmatch 'corecrt_wio\.h') {
$content = "#include <corecrt_wio.h>`r`n" + $content
Set-Content -Path $ioutilHeader -Value $content -NoNewline -Encoding utf8
Write-Host "[CI] Patched $ioutilHeader with corecrt_wio.h."
}
}
$ioutilHeader2 = Join-Path $phpDir "include\win32\ioutil.h"
if (Test-Path $ioutilHeader2) {
$content2 = Get-Content $ioutilHeader2 -Raw
if ($content2 -notmatch 'corecrt_wio\.h') {
$content2 = "#include <corecrt_wio.h>`r`n" + $content2
Set-Content -Path $ioutilHeader2 -Value $content2 -NoNewline -Encoding utf8
Write-Host "[CI] Patched $ioutilHeader2 with corecrt_wio.h."
}
}
}
"PHP_HOME=$phpDir" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8
# phpx 2.7.0 no longer honors GMP_MPFR_ROOT: it resolves gmp/gmpxx/mpfr
# through the PHP SDK include/lib directories, so stage them there.
- name: Stage Windows GMP and MPFR into PHP SDK
if: runner.os == 'Windows'
shell: powershell
run: |
$ErrorActionPreference = 'Stop'
$cacheRoot = Join-Path $env:RUNNER_TEMP "typephp-cache\vcpkg-x64-windows"
$phpDir = $env:PHP_HOME
if (-not $phpDir) {
throw "[CI] PHP_HOME is not set; Devpack step must run first"
}
foreach ($h in @('gmp.h', 'gmpxx.h', 'mpfr.h')) {
Copy-Item (Join-Path $cacheRoot "include\$h") (Join-Path $phpDir 'SDK\include') -Force
}
Copy-Item (Join-Path $cacheRoot 'lib\gmp.lib'), (Join-Path $cacheRoot 'lib\gmpxx.lib'), (Join-Path $cacheRoot 'lib\mpfr.lib') (Join-Path $phpDir 'SDK\lib') -Force
Copy-Item (Join-Path $cacheRoot 'bin\*.dll') $phpDir -Force
Write-Host "[CI] Staged GMP/MPFR into $phpDir\SDK (include + lib) and DLLs beside php.exe"
- name: Patch PHPX headers for MSVC C++ compatibility
if: runner.os == 'Windows'
shell: powershell
run: |
$phpxHeader = Join-Path $env:GITHUB_WORKSPACE "vendor\swoole\phpx\include\phpx.h"
if (Test-Path $phpxHeader) {
$content = Get-Content $phpxHeader -Raw
if ($content -notmatch 'corecrt_wio\.h') {
$prelude = "#if defined(WIN32) || defined(_WIN32)`r`n#include <corecrt.h>`r`n#include <cstdlib>`r`n#include <cmath>`r`n#include <stdlib.h>`r`n#include <io.h>`r`n#include <sys/stat.h>`r`n#include <corecrt_wio.h>`r`n#endif`r`n"
$content = $content -replace '(#pragma once\r?\n)', "`$1`r`n$prelude`r`n"
Set-Content -Path $phpxHeader -Value $content -NoNewline -Encoding utf8
Write-Host "[CI] Patched $phpxHeader with MSVC CRT prelude."
}
}
# phpx 2.7.0 consumes prebuilt mpdecimal import libraries on Windows
# instead of compiling thirdparty/mpdecimal from source, so the bundled
# vcbuild recipe has to run before the phpx CMake configure step.
- name: Build mpdecimal on Windows
if: runner.os == 'Windows'
shell: pwsh
run: |
$ErrorActionPreference = 'Stop'
Push-Location (Join-Path $env:GITHUB_WORKSPACE 'vendor\swoole\phpx\thirdparty\mpdecimal\vcbuild')
try {
& cmd.exe /d /s /c vcbuild64.bat
if ($LASTEXITCODE -ne 0) {
throw "mpdecimal build failed with exit code $LASTEXITCODE"
}
} finally {
Pop-Location
}
- name: Stage mpdecimal into PHP SDK
if: runner.os == 'Windows'
shell: pwsh
run: |
$ErrorActionPreference = 'Stop'
$dist = Join-Path $env:GITHUB_WORKSPACE 'vendor\swoole\phpx\thirdparty\mpdecimal\vcbuild\dist64'
$sdkInclude = Join-Path $env:PHP_HOME 'SDK\include'
$sdkLib = Join-Path $env:PHP_HOME 'SDK\lib'
Copy-Item (Join-Path $dist '*.lib') $sdkLib -Force
Copy-Item (Join-Path $dist '*.dll') $sdkLib -Force
Copy-Item (Join-Path $dist '*.dll') $env:PHP_HOME -Force
Copy-Item (Join-Path $dist 'mpdecimal.h') $sdkInclude -Force
Copy-Item (Join-Path $dist 'decimal.hh') $sdkInclude -Force
- name: Build PHPX Library on Windows
if: runner.os == 'Windows'
shell: cmd
run: |
cd "%GITHUB_WORKSPACE%\vendor\swoole\phpx"
if not exist "build" mkdir "build"
cd build
rem find_library(NAMES mpdec-4.0.1) cannot match the ".dll.lib" double suffix, so both import libraries are passed explicitly.
cmake .. -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Release -Dphp_dir="%PHP_HOME%" -DBUILD_TESTS=OFF -DBUILD_EXT=OFF -DCMAKE_CXX_FLAGS="/DNOMINMAX" -DMPDECIMAL_LIBRARY="%PHP_HOME%\SDK\lib\libmpdec-4.0.1.dll.lib" -DMPDECIMALXX_LIBRARY="%PHP_HOME%\SDK\lib\libmpdec++-4.0.1.dll.lib"
if not exist "%GITHUB_WORKSPACE%\vendor\swoole\phpx\lib" mkdir "%GITHUB_WORKSPACE%\vendor\swoole\phpx\lib"
nmake phpx
if not exist "%GITHUB_WORKSPACE%\vendor\swoole\phpx\build\phpx.dll" (
echo [ERROR] PHPX runtime library was not produced in the build directory.
exit /b 1
)
if not exist "%GITHUB_WORKSPACE%\vendor\swoole\phpx\lib\phpx.lib" if exist "phpx.lib" copy /y "phpx.lib" "%GITHUB_WORKSPACE%\vendor\swoole\phpx\lib\"
if not exist "%GITHUB_WORKSPACE%\vendor\swoole\phpx\lib\phpx.lib" (
echo [ERROR] PHPX import library was not produced by CMake.
dir /s /b "%GITHUB_WORKSPACE%\vendor\swoole\phpx\*.lib"
exit /b 1
)
copy /y "%GITHUB_WORKSPACE%\vendor\swoole\phpx\lib\phpx.lib" "%GITHUB_WORKSPACE%\vendor\swoole\phpx\"
dir "%GITHUB_WORKSPACE%\vendor\swoole\phpx\lib"
- name: Build and Package on Windows
if: runner.os == 'Windows'
shell: cmd
run: |
call package.bat
if errorlevel 1 exit /b 1
powershell Compress-Archive -Path dist/* -DestinationPath ${{ matrix.archive_name }}
# ---------------- 上传构建产物 (Artifacts) ----------------
- name: Upload Build Artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.archive_name }}
path: ${{ matrix.archive_name }}
# ---------------- 发布 GitHub Release ----------------
- name: Create Release and Upload Asset
if: startsWith(github.ref, 'refs/tags/')
uses: softprops/action-gh-release@v2
with:
files: ${{ matrix.archive_name }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}