Skip to content

Commit 71f169b

Browse files
Enhance build-unix.yml with shared extensions support
Updated descriptions for extensions and added shared extensions support in the build workflow.
1 parent f680731 commit 71f169b

1 file changed

Lines changed: 57 additions & 12 deletions

File tree

.github/workflows/build-unix.yml

Lines changed: 57 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,13 @@ on:
2626
- '8.2'
2727
- '8.1'
2828
extensions:
29-
description: Extensions to build (comma separated)
29+
description: Extensions to build statically (comma separated)
3030
required: true
3131
type: string
32+
shared-extensions:
33+
description: Extensions to build shared (comma separated, optional)
34+
required: false
35+
type: string
3236
extra-libs:
3337
description: Extra libraries to build (optional, comma separated)
3438
type: string
@@ -66,9 +70,13 @@ on:
6670
default: '8.4'
6771
type: string
6872
extensions:
69-
description: Extensions to build (comma separated)
73+
description: Extensions to build statically (comma separated)
7074
required: true
7175
type: string
76+
shared-extensions:
77+
description: Extensions to build shared (comma separated, optional)
78+
required: false
79+
type: string
7280
extra-libs:
7381
description: Extra libraries to build (optional, comma separated)
7482
type: string
@@ -95,7 +103,7 @@ on:
95103
default: false
96104

97105
env:
98-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
106+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
99107

100108
jobs:
101109
define-build:
@@ -105,13 +113,15 @@ jobs:
105113
run: ${{ steps.gendef.outputs.run }}
106114
download: ${{ steps.gendef.outputs.download }}
107115
build: ${{ steps.gendef.outputs.build }}
116+
has-shared: ${{ steps.gendef.outputs.has-shared }}
108117
steps:
109118
- name: "Checkout"
110119
uses: actions/checkout@v4
111120

112121
- name: "Define"
113122
id: gendef
114123
run: |
124+
# 1. Select the base command and runner based on OS
115125
case "${{ inputs.os }}" in
116126
linux-x86_64)
117127
DOWN_CMD="./bin/spc-alpine-docker download"
@@ -144,8 +154,29 @@ jobs:
144154
RUNS_ON="macos-15"
145155
;;
146156
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 }}"
157+
158+
# 2. Combine static and shared extensions for the download step
159+
ALL_EXTENSIONS="${{ inputs.extensions }}"
160+
if [ -n "${{ inputs.shared-extensions }}" ]; then
161+
ALL_EXTENSIONS="${ALL_EXTENSIONS},${{ inputs.shared-extensions }}"
162+
echo "has-shared=true" >> "$GITHUB_OUTPUT"
163+
else
164+
echo "has-shared=false" >> "$GITHUB_OUTPUT"
165+
fi
166+
167+
# 3. Construct Download Command
168+
DOWN_CMD="$DOWN_CMD --with-php=${{ inputs.php-version }} --for-extensions=${ALL_EXTENSIONS} --ignore-cache-sources=php-src"
169+
170+
# 4. Construct Build Command
171+
# Add static extensions (passed as main argument for --build-cli usually, or --build-cli=... depending on spc version logic)
172+
# Assuming the original logic BUILD_CMD="$BUILD_CMD ${{ inputs.extensions }}" works for the main target:
173+
BUILD_CMD="$BUILD_CMD --build-cli=\"${{ inputs.extensions }}\""
174+
175+
# Add shared extensions flag if present
176+
if [ -n "${{ inputs.shared-extensions }}" ]; then
177+
BUILD_CMD="$BUILD_CMD --build-shared=\"${{ inputs.shared-extensions }}\""
178+
fi
179+
149180
if [ -n "${{ inputs.extra-libs }}" ]; then
150181
DOWN_CMD="$DOWN_CMD --for-libs=${{ inputs.extra-libs }}"
151182
BUILD_CMD="$BUILD_CMD --with-libs=${{ inputs.extra-libs }}"
@@ -157,18 +188,19 @@ jobs:
157188
if [ ${{ inputs.prefer-pre-built }} == true ]; then
158189
DOWN_CMD="$DOWN_CMD --prefer-pre-built"
159190
fi
160-
if [ ${{ inputs.build-cli }} == true ]; then
161-
BUILD_CMD="$BUILD_CMD --build-cli"
162-
fi
191+
# build-cli is handled above in the main extension list logic usually,
192+
# but we keep these flags just in case the wrapper script needs them.
163193
if [ ${{ inputs.build-micro }} == true ]; then
164194
BUILD_CMD="$BUILD_CMD --build-micro"
165195
fi
166196
if [ ${{ inputs.build-fpm }} == true ]; then
167197
BUILD_CMD="$BUILD_CMD --build-fpm"
168198
fi
199+
169200
echo 'download='"$DOWN_CMD" >> "$GITHUB_OUTPUT"
170201
echo 'build='"$BUILD_CMD" >> "$GITHUB_OUTPUT"
171202
echo 'run='"$RUNS_ON" >> "$GITHUB_OUTPUT"
203+
172204
build:
173205
name: "Build ${{ inputs.version }} on ${{ inputs.os }}"
174206
runs-on: ${{ needs.define-build.outputs.run }}
@@ -193,14 +225,13 @@ jobs:
193225
uses: actions/cache@v4
194226
with:
195227
path: downloads
196-
key: php-dependencies-${{ inputs.os }}
228+
key: php-dependencies-${{ inputs.os }}-${{ inputs.php-version }} # Added version to key for safety
229+
197230
- name: "Download sources"
198231
run: ${{ needs.define-build.outputs.download }}
232+
199233
- name: "Build PHP"
200234
run: ${{ needs.define-build.outputs.build }}
201-
# - name: Setup tmate session
202-
# if: ${{ failure() }}
203-
# uses: mxschmitt/action-tmate@v3
204235

205236
# Upload cli executable
206237
- if: ${{ inputs.build-cli == true }}
@@ -226,12 +257,26 @@ jobs:
226257
name: php-fpm-${{ inputs.php-version }}-${{ inputs.os }}
227258
path: buildroot/bin/php-fpm
228259

260+
# NEW: Upload Shared Extensions (.so files)
261+
- if: ${{ needs.define-build.outputs.has-shared == 'true' }}
262+
name: "Upload Shared Extensions"
263+
uses: actions/upload-artifact@v4
264+
with:
265+
name: php-extensions-${{ inputs.php-version }}-${{ inputs.os }}
266+
# SPC outputs shared libs to buildroot/lib/ or buildroot/modules/ depending on version.
267+
# Using a wildcard pattern to catch it.
268+
path: |
269+
buildroot/lib/extensions/*.so
270+
buildroot/modules/*.so
271+
buildroot/lib/*.so
272+
229273
# Upload extensions metadata
230274
- uses: actions/upload-artifact@v4
231275
name: "Upload License Files"
232276
with:
233277
name: license-files-${{ inputs.php-version }}-${{ inputs.os }}
234278
path: buildroot/license/
279+
235280
- uses: actions/upload-artifact@v4
236281
name: "Upload Build Metadata"
237282
with:

0 commit comments

Comments
 (0)