-
Notifications
You must be signed in to change notification settings - Fork 84
190 lines (166 loc) · 7.03 KB
/
Copy pathbuild-php-cli-binaries.yml
File metadata and controls
190 lines (166 loc) · 7.03 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
name: Build PHP CLI Binaries
on:
workflow_dispatch:
inputs:
php_version:
description: PHP patch version to build
required: true
default: 8.4.20
spc_ref:
description: static-php-cli ref
required: true
default: 2.8.5
prefer_pre_built:
description: Prefer pre-built static-php-cli libraries
required: true
type: boolean
default: true
debug:
description: Enable static-php-cli debug logs
required: true
type: boolean
default: false
permissions:
contents: read
env:
GITHUB_TOKEN: ${{ github.token }}
jobs:
build:
name: Build ${{ matrix.target }}
runs-on: ${{ matrix.runner }}
timeout-minutes: 240
strategy:
fail-fast: false
matrix:
include:
- target: macos-aarch64
runner: macos-15
artifact_platform: macos
artifact_arch: aarch64
archive_extension: tar.gz
binary_name: php
extensions: &macos_php_extensions apcu,bcmath,calendar,ctype,curl,dba,dom,exif,fileinfo,filter,ftp,gd,gettext,iconv,igbinary,imagick,intl,mbregex,mbstring,mysqli,mysqlnd,opcache,openssl,pcntl,pdo,pdo_mysql,pdo_sqlite,phar,posix,readline,redis,session,shmop,simplexml,sockets,sodium,sqlite3,ssh2,tokenizer,xml,xmlreader,xmlwriter,xsl,yaml,zip,zlib
- target: macos-x86_64
runner: macos-15-intel
artifact_platform: macos
artifact_arch: x86_64
archive_extension: tar.gz
binary_name: php
extensions: *macos_php_extensions
- target: windows-x86_64
runner: windows-latest
artifact_platform: windows
artifact_arch: x86_64
archive_extension: zip
binary_name: php.exe
# static-php-cli 2.8.5 has Windows builders for intl and sodium, but not gettext/libxslt.
extensions: apcu,bcmath,calendar,ctype,curl,dba,dom,exif,fileinfo,filter,ftp,gd,iconv,igbinary,intl,mbregex,mbstring,mysqli,mysqlnd,opcache,openssl,pdo,pdo_mysql,pdo_sqlite,phar,redis,session,shmop,simplexml,sockets,sodium,sqlite3,ssh2,tokenizer,xml,xmlreader,xmlwriter,yaml,zip,zlib
env:
PHP_VERSION: ${{ github.event_name == 'workflow_dispatch' && inputs.php_version || '8.4.20' }}
SPC_REF: ${{ github.event_name == 'workflow_dispatch' && inputs.spc_ref || '2.8.5' }}
PHP_CLI_EXTENSIONS: ${{ matrix.extensions }}
PHP_CLI_ARTIFACT_PLATFORM: ${{ matrix.artifact_platform }}
PHP_CLI_ARTIFACT_ARCH: ${{ matrix.artifact_arch }}
PHP_CLI_ARCHIVE_EXTENSION: ${{ matrix.archive_extension }}
PHP_CLI_BINARY_NAME: ${{ matrix.binary_name }}
PREFER_PRE_BUILT: ${{ github.event_name != 'workflow_dispatch' || inputs.prefer_pre_built }}
SPC_DEBUG: ${{ github.event_name == 'workflow_dispatch' && inputs.debug || false }}
steps:
- name: Checkout Studio
uses: actions/checkout@v6
- name: Checkout static-php-cli
uses: actions/checkout@v6
with:
repository: crazywhalecc/static-php-cli
ref: ${{ env.SPC_REF }}
path: .cache/static-php-cli
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
coverage: none
tools: composer:v2
php-version: 8.4
ini-values: memory_limit=-1
extensions: curl, openssl, mbstring
env:
phpts: nts
- name: Install static-php-cli dependencies
working-directory: .cache/static-php-cli
run: composer install --no-dev --no-interaction --prefer-dist --classmap-authoritative
- name: Build PHP CLI on macOS
if: runner.os == 'macOS'
working-directory: .cache/static-php-cli
shell: bash
run: |
set -euo pipefail
download_args=(--with-php="$PHP_VERSION" --for-extensions="$PHP_CLI_EXTENSIONS" --ignore-cache-sources=php-src)
build_args=("$PHP_CLI_EXTENSIONS" --build-cli)
if [ "$PREFER_PRE_BUILT" = "true" ]; then
download_args+=(--prefer-pre-built)
fi
if [ "$SPC_DEBUG" = "true" ]; then
download_args+=(--debug)
build_args+=(--debug)
fi
php bin/spc doctor --auto-fix
php bin/spc download "${download_args[@]}"
php bin/spc build "${build_args[@]}"
- name: Build PHP CLI on Windows
if: runner.os == 'Windows'
working-directory: .cache/static-php-cli
shell: pwsh
run: |
$downloadArgs = @(
"--with-php=$env:PHP_VERSION",
"--for-extensions=$env:PHP_CLI_EXTENSIONS",
"--ignore-cache-sources=php-src"
)
$buildArgs = @( $env:PHP_CLI_EXTENSIONS, "--build-cli" )
if ( $env:PREFER_PRE_BUILT -eq "true" ) {
$downloadArgs += "--prefer-pre-built"
}
if ( $env:SPC_DEBUG -eq "true" ) {
$downloadArgs += "--debug"
$buildArgs += "--debug"
}
php bin/spc doctor --auto-fix
php bin/spc download @downloadArgs
php bin/spc build @buildArgs
- name: Package macOS artifact
if: runner.os == 'macOS'
shell: bash
run: |
set -euo pipefail
out_dir="$GITHUB_WORKSPACE/out/php-binaries"
artifact="php-${PHP_VERSION}-cli-${PHP_CLI_ARTIFACT_PLATFORM}-${PHP_CLI_ARTIFACT_ARCH}.${PHP_CLI_ARCHIVE_EXTENSION}"
mkdir -p "$out_dir"
cp "$GITHUB_WORKSPACE/.cache/static-php-cli/buildroot/bin/$PHP_CLI_BINARY_NAME" "$RUNNER_TEMP/php"
chmod +x "$RUNNER_TEMP/php"
xattr -cr "$RUNNER_TEMP/php"
tar -czf "$out_dir/$artifact" -C "$RUNNER_TEMP" php
shasum -a 256 "$out_dir/$artifact" | awk '{print $1}' > "$out_dir/$artifact.sha256"
- name: Package Windows artifact
if: runner.os == 'Windows'
shell: pwsh
run: |
$outDir = Join-Path $env:GITHUB_WORKSPACE 'out/php-binaries'
$artifact = "php-$env:PHP_VERSION-cli-$env:PHP_CLI_ARTIFACT_PLATFORM-$env:PHP_CLI_ARTIFACT_ARCH.$env:PHP_CLI_ARCHIVE_EXTENSION"
$source = Join-Path $env:GITHUB_WORKSPACE ".cache/static-php-cli/buildroot/bin/$env:PHP_CLI_BINARY_NAME"
$dest = Join-Path $env:RUNNER_TEMP $env:PHP_CLI_BINARY_NAME
$archive = Join-Path $outDir $artifact
New-Item -ItemType Directory -Force $outDir | Out-Null
Copy-Item -Force $source $dest
Compress-Archive -Force -Path $dest -DestinationPath $archive
(Get-FileHash $archive -Algorithm SHA256).Hash.ToLower() | Set-Content -NoNewline "$archive.sha256"
- name: Upload PHP CLI artifact
uses: actions/upload-artifact@v4
with:
name: php-${{ env.PHP_VERSION }}-cli-${{ matrix.target }}
path: out/php-binaries/*
- name: Upload static-php-cli logs
if: ${{ failure() }}
uses: actions/upload-artifact@v4
with:
name: spc-logs-${{ matrix.target }}
path: .cache/static-php-cli/log/*.log
if-no-files-found: ignore