Skip to content

Commit 88d2f0f

Browse files
authored
StaticPHP v3 alpha1 (#980)
2 parents f6c818d + 9d4a8dd commit 88d2f0f

1,060 files changed

Lines changed: 47243 additions & 35191 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/build-unix.yml

Lines changed: 101 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ on:
2929
description: Extensions to build (comma separated)
3030
required: true
3131
type: string
32+
shared-extensions:
33+
description: Shared extensions to build (optional, comma separated)
34+
type: string
3235
extra-libs:
3336
description: Extra libraries to build (optional, comma separated)
3437
type: string
@@ -42,10 +45,22 @@ on:
4245
build-fpm:
4346
description: Build fpm binary
4447
type: boolean
48+
build-frankenphp:
49+
description: Build frankenphp binary (requires ZTS)
50+
type: boolean
51+
default: false
52+
enable-zts:
53+
description: Enable ZTS
54+
type: boolean
55+
default: false
4556
prefer-pre-built:
4657
description: Prefer pre-built binaries (reduce build time)
4758
type: boolean
4859
default: true
60+
with-suggested-libs:
61+
description: Build with suggested libs
62+
type: boolean
63+
default: true
4964
debug:
5065
description: Show full build logs
5166
type: boolean
@@ -69,6 +84,9 @@ on:
6984
description: Extensions to build (comma separated)
7085
required: true
7186
type: string
87+
shared-extensions:
88+
description: Shared extensions to build (optional, comma separated)
89+
type: string
7290
extra-libs:
7391
description: Extra libraries to build (optional, comma separated)
7492
type: string
@@ -82,10 +100,22 @@ on:
82100
build-fpm:
83101
description: Build fpm binary
84102
type: boolean
103+
build-frankenphp:
104+
description: Build frankenphp binary (requires ZTS)
105+
type: boolean
106+
default: false
107+
enable-zts:
108+
description: Enable ZTS
109+
type: boolean
110+
default: false
85111
prefer-pre-built:
86112
description: Prefer pre-built binaries (reduce build time)
87113
type: boolean
88114
default: true
115+
with-suggested-libs:
116+
description: Include suggested libs
117+
type: boolean
118+
default: false
89119
debug:
90120
description: Show full build logs
91121
type: boolean
@@ -144,8 +174,19 @@ jobs:
144174
RUNS_ON="macos-15"
145175
;;
146176
esac
147-
DOWN_CMD="$DOWN_CMD --with-php=${{ inputs.php-version }} --for-extensions=${{ inputs.extensions }} --ignore-cache-sources=php-src"
148-
BUILD_CMD="$BUILD_CMD ${{ inputs.extensions }}"
177+
STATIC_EXTS="${{ inputs.extensions }}"
178+
SHARED_EXTS="${{ inputs['shared-extensions'] }}"
179+
BUILD_FRANKENPHP="${{ inputs['build-frankenphp'] }}"
180+
ENABLE_ZTS="${{ inputs['enable-zts'] }}"
181+
ALL_EXTS="$STATIC_EXTS"
182+
if [ -n "$SHARED_EXTS" ]; then
183+
ALL_EXTS="$ALL_EXTS,$SHARED_EXTS"
184+
fi
185+
DOWN_CMD="$DOWN_CMD --with-php=${{ inputs.php-version }} --for-extensions=$ALL_EXTS --ignore-cache-sources=php-src"
186+
BUILD_CMD="$BUILD_CMD $STATIC_EXTS"
187+
if [ -n "$SHARED_EXTS" ]; then
188+
BUILD_CMD="$BUILD_CMD --build-shared=$SHARED_EXTS"
189+
fi
149190
if [ -n "${{ inputs.extra-libs }}" ]; then
150191
DOWN_CMD="$DOWN_CMD --for-libs=${{ inputs.extra-libs }}"
151192
BUILD_CMD="$BUILD_CMD --with-libs=${{ inputs.extra-libs }}"
@@ -157,6 +198,9 @@ jobs:
157198
if [ ${{ inputs.prefer-pre-built }} == true ]; then
158199
DOWN_CMD="$DOWN_CMD --prefer-pre-built"
159200
fi
201+
if [ ${{ inputs.with-suggested-libs }} == true ]; then
202+
BUILD_CMD="$BUILD_CMD --with-suggested-libs"
203+
fi
160204
if [ ${{ inputs.build-cli }} == true ]; then
161205
BUILD_CMD="$BUILD_CMD --build-cli"
162206
fi
@@ -166,6 +210,12 @@ jobs:
166210
if [ ${{ inputs.build-fpm }} == true ]; then
167211
BUILD_CMD="$BUILD_CMD --build-fpm"
168212
fi
213+
if [ "$BUILD_FRANKENPHP" = "true" ]; then
214+
BUILD_CMD="$BUILD_CMD --build-frankenphp"
215+
fi
216+
if [ "$ENABLE_ZTS" = "true" ]; then
217+
BUILD_CMD="$BUILD_CMD --enable-zts"
218+
fi
169219
echo 'download='"$DOWN_CMD" >> "$GITHUB_OUTPUT"
170220
echo 'build='"$BUILD_CMD" >> "$GITHUB_OUTPUT"
171221
echo 'run='"$RUNS_ON" >> "$GITHUB_OUTPUT"
@@ -188,6 +238,27 @@ jobs:
188238
env:
189239
phpts: nts
190240

241+
- if: ${{ inputs['build-frankenphp'] == true }}
242+
name: "Install go-xcaddy for FrankenPHP"
243+
run: |
244+
case "${{ inputs.os }}" in
245+
linux-x86_64|linux-aarch64)
246+
./bin/spc-alpine-docker install-pkg go-xcaddy
247+
;;
248+
linux-x86_64-glibc|linux-aarch64-glibc)
249+
./bin/spc-gnu-docker install-pkg go-xcaddy
250+
;;
251+
macos-x86_64|macos-aarch64)
252+
composer update --no-dev --classmap-authoritative
253+
./bin/spc doctor --auto-fix
254+
./bin/spc install-pkg go-xcaddy
255+
;;
256+
*)
257+
echo "Unsupported OS for go-xcaddy install: ${{ inputs.os }}"
258+
exit 1
259+
;;
260+
esac
261+
191262
# Cache downloaded source
192263
- id: cache-download
193264
uses: actions/cache@v4
@@ -202,37 +273,60 @@ jobs:
202273
# if: ${{ failure() }}
203274
# uses: mxschmitt/action-tmate@v3
204275

276+
# Upload debug logs
277+
- if: ${{ inputs.debug && failure() }}
278+
name: "Upload build logs on failure"
279+
uses: actions/upload-artifact@v7
280+
with:
281+
name: spc-logs-${{ inputs.php-version }}-${{ inputs.os }}
282+
path: log/*.log
283+
205284
# Upload cli executable
206285
- if: ${{ inputs.build-cli == true }}
207286
name: "Upload PHP cli SAPI"
208-
uses: actions/upload-artifact@v4
287+
uses: actions/upload-artifact@v7
209288
with:
210289
name: php-cli-${{ inputs.php-version }}-${{ inputs.os }}
211290
path: buildroot/bin/php
212291

213292
# Upload micro self-extracted executable
214293
- if: ${{ inputs.build-micro == true }}
215294
name: "Upload PHP micro SAPI"
216-
uses: actions/upload-artifact@v4
295+
uses: actions/upload-artifact@v7
217296
with:
218297
name: php-micro-${{ inputs.php-version }}-${{ inputs.os }}
219298
path: buildroot/bin/micro.sfx
220299

221300
# Upload fpm executable
222301
- if: ${{ inputs.build-fpm == true }}
223302
name: "Upload PHP fpm SAPI"
224-
uses: actions/upload-artifact@v4
303+
uses: actions/upload-artifact@v7
225304
with:
226305
name: php-fpm-${{ inputs.php-version }}-${{ inputs.os }}
227306
path: buildroot/bin/php-fpm
228307

308+
# Upload frankenphp executable
309+
- if: ${{ inputs['build-frankenphp'] == true }}
310+
name: "Upload FrankenPHP SAPI"
311+
uses: actions/upload-artifact@v7
312+
with:
313+
name: php-frankenphp-${{ inputs.php-version }}-${{ inputs.os }}
314+
path: buildroot/bin/frankenphp
315+
229316
# Upload extensions metadata
230-
- uses: actions/upload-artifact@v4
317+
- if: ${{ inputs['shared-extensions'] != '' }}
318+
name: "Upload shared extensions"
319+
uses: actions/upload-artifact@v7
320+
with:
321+
name: php-shared-ext-${{ inputs.php-version }}-${{ inputs.os }}
322+
path: |
323+
buildroot/modules/*.so
324+
- uses: actions/upload-artifact@v7
231325
name: "Upload License Files"
232326
with:
233327
name: license-files-${{ inputs.php-version }}-${{ inputs.os }}
234328
path: buildroot/license/
235-
- uses: actions/upload-artifact@v4
329+
- uses: actions/upload-artifact@v7
236330
name: "Upload Build Metadata"
237331
with:
238332
name: build-meta-${{ inputs.php-version }}-${{ inputs.os }}

.github/workflows/build-windows-x86_64.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ on:
2929
description: prefer pre-built binaries (reduce build time)
3030
type: boolean
3131
default: true
32+
with-suggested-libs:
33+
description: Build with suggested libs
34+
type: boolean
35+
default: true
3236
debug:
3337
description: enable debug logs
3438
type: boolean
@@ -90,24 +94,24 @@ jobs:
9094

9195
# Upload cli executable
9296
- if: ${{ inputs.build-cli == true }}
93-
uses: actions/upload-artifact@v4
97+
uses: actions/upload-artifact@v7
9498
with:
9599
name: php-${{ inputs.version }}
96100
path: buildroot/bin/php.exe
97101

98102
# Upload micro self-extracted executable
99103
- if: ${{ inputs.build-micro == true }}
100-
uses: actions/upload-artifact@v4
104+
uses: actions/upload-artifact@v7
101105
with:
102106
name: micro-${{ inputs.version }}
103107
path: buildroot/bin/micro.sfx
104108

105109
# Upload extensions metadata
106-
- uses: actions/upload-artifact@v4
110+
- uses: actions/upload-artifact@v7
107111
with:
108112
name: license-files
109113
path: buildroot/license/
110-
- uses: actions/upload-artifact@v4
114+
- uses: actions/upload-artifact@v7
111115
with:
112116
name: build-meta
113117
path: |

.github/workflows/release-build.yml

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ name: Build SPC Binary
22

33
on:
44
push:
5-
branches: [ "main" ]
5+
branches: [ "main", "v3" ]
66
pull_request:
7-
branches: [ "main" ]
7+
branches: [ "main", "v3" ]
88
paths:
99
- '.github/workflows/release-build.yml'
1010
release:
@@ -40,7 +40,7 @@ jobs:
4040
filename: "spc-windows-x64.exe"
4141
steps:
4242
- name: "Checkout"
43-
uses: "actions/checkout@v4"
43+
uses: "actions/checkout@v5"
4444

4545
- if: inputs.debug == true
4646
run: echo "SPC_BUILD_DEBUG=--debug" >> $GITHUB_ENV
@@ -60,7 +60,7 @@ jobs:
6060
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
6161
6262
- name: "Cache Composer dependencies"
63-
uses: "actions/cache@v4"
63+
uses: "actions/cache@v5"
6464
with:
6565
path: "${{ steps.composer-cache.outputs.dir }}"
6666
key: "php-${{ env.PHP_VERSION }}-locked-composer-${{ hashFiles('**/composer.lock') }}"
@@ -101,7 +101,7 @@ jobs:
101101
tar -czf ${{ matrix.operating-system.filename }} spc
102102
# validate spc binary
103103
if [ "${{ matrix.operating-system.name }}" == "linux-x86_64" ]; then
104-
./spc dev:extensions
104+
./spc dev:info php
105105
fi
106106
fi
107107
@@ -120,20 +120,32 @@ jobs:
120120
with:
121121
files: dist/${{ matrix.operating-system.filename }}
122122

123-
- name: "Deploy to self-hosted OSS"
124-
# only run this step if the repository is static-php-cli and the branch is main
125-
if: github.repository == 'crazywhalecc/static-php-cli' && github.ref == 'refs/heads/main'
123+
- name: "Deploy to self-hosted OSS (latest)"
124+
# only run this step if the repository is static-php-cli and is release tag
125+
if: ${{ github.repository == 'crazywhalecc/static-php-cli' && startsWith(github.ref, 'refs/tags/') }}
126126
uses: static-php/upload-s3-action@v1.0.0
127127
with:
128128
aws_key_id: ${{ secrets.AWS_KEY_ID }}
129129
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
130130
aws_bucket: ${{ secrets.AWS_BUCKET }}
131131
source_dir: "dist/"
132-
destination_dir: static-php-cli/spc-bin/nightly/
132+
destination_dir: v3/spc-bin/latest/
133+
endpoint: ${{ secrets.AWS_ENDPOINT }}
134+
135+
- name: "Deploy to self-hosted OSS (versioned)"
136+
# only run this step if the repository is static-php-cli and is release tag
137+
if: ${{ github.repository == 'crazywhalecc/static-php-cli' && startsWith(github.ref, 'refs/tags/') }}
138+
uses: static-php/upload-s3-action@v1.0.0
139+
with:
140+
aws_key_id: ${{ secrets.AWS_KEY_ID }}
141+
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
142+
aws_bucket: ${{ secrets.AWS_BUCKET }}
143+
source_dir: "dist/"
144+
destination_dir: v3/spc-bin/${{ github.ref_name }}/
133145
endpoint: ${{ secrets.AWS_ENDPOINT }}
134146

135147
- name: "Upload Artifact"
136-
uses: actions/upload-artifact@v4
148+
uses: actions/upload-artifact@v7
137149
with:
138150
path: spc${{ env.SUFFIX }}
139151
name: spc-${{ matrix.operating-system.name }}${{ env.SUFFIX }}
@@ -156,10 +168,10 @@ jobs:
156168
os: "windows-latest"
157169
steps:
158170
- name: "Checkout"
159-
uses: actions/checkout@v4
171+
uses: actions/checkout@v5
160172

161173
- name: "Download Artifact"
162-
uses: actions/download-artifact@v4
174+
uses: actions/download-artifact@v5
163175
env:
164176
SUFFIX: ${{ matrix.operating-system.name == 'windows-x64' && '.exe' || '' }}
165177
with:
@@ -172,4 +184,4 @@ jobs:
172184
- name: "Run SPC Tests"
173185
env:
174186
SUFFIX: ${{ matrix.operating-system.name == 'windows-x64' && '.exe' || '' }}
175-
run: ./spc${{ env.SUFFIX }} dev:extensions
187+
run: ./spc${{ env.SUFFIX }} dev:info php

.github/workflows/tests.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Tests
22

33
on:
44
pull_request:
5-
branches: [ "main" ]
5+
branches: [ "main", "v3" ]
66
types: [ opened, synchronize, reopened ]
77
paths:
88
- 'src/**'
@@ -106,6 +106,7 @@ jobs:
106106
run: SPC_LIBC=glibc vendor/bin/phpunit tests/ --no-coverage
107107

108108
define-matrix:
109+
if: false # TODO: enable when refactoring workflows
109110
name: "Define Matrix"
110111
runs-on: ubuntu-latest
111112
outputs:
@@ -131,6 +132,7 @@ jobs:
131132
132133
133134
build:
135+
if: false
134136
name: "Build PHP Test (PHP ${{ matrix.php }} ${{ matrix.os }})"
135137
runs-on: ${{ matrix.os }}
136138
needs: [define-matrix, php-cs-fixer, phpstan, phpunit]
@@ -204,7 +206,7 @@ jobs:
204206

205207
- name: "Upload logs"
206208
if: ${{ always() && hashFiles('log/**') != '' }}
207-
uses: actions/upload-artifact@v4
209+
uses: actions/upload-artifact@v7
208210
with:
209211
name: build-logs-${{ matrix.os }}-${{ matrix.php }}
210212
path: log

0 commit comments

Comments
 (0)