-
-
Notifications
You must be signed in to change notification settings - Fork 252
190 lines (179 loc) · 6.02 KB
/
build-unix.yml
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: "CI on Unix"
on:
workflow_dispatch:
inputs:
os:
required: true
description: Build target OS
type: choice
options:
- 'linux-x86_64'
- 'linux-aarch64'
- 'macos-x86_64'
- 'macos-aarch64'
php-version:
required: true
description: PHP version to compile
default: '8.3'
type: choice
options:
- '8.4'
- '8.3'
- '8.2'
- '8.1'
- '8.0'
extensions:
description: Extensions to build (comma separated)
required: true
type: string
extra-libs:
description: Extra libraries to build (optional, comma separated)
type: string
build-cli:
description: Build cli binary
default: true
type: boolean
build-micro:
description: Build phpmicro binary
type: boolean
build-fpm:
description: Build fpm binary
type: boolean
prefer-pre-built:
description: Prefer pre-built binaries (reduce build time)
type: boolean
default: true
debug:
description: Show full build logs
type: boolean
no-strip:
description: Keep debug symbols for debugging
type: boolean
default: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
define-build:
name: "Define Build Scripts"
runs-on: ubuntu-latest
outputs:
run: ${{ steps.gendef.outputs.run }}
download: ${{ steps.gendef.outputs.download }}
build: ${{ steps.gendef.outputs.build }}
steps:
- name: "Checkout"
uses: actions/checkout@v4
- name: "Define"
id: gendef
run: |
case "${{ inputs.os }}" in
linux-x86_64)
DOWN_CMD="./bin/spc-alpine-docker download"
BUILD_CMD="./bin/spc-alpine-docker build"
RUNS_ON="ubuntu-latest"
;;
linux-aarch64)
DOWN_CMD="SPC_USE_ARCH=aarch64 ./bin/spc-alpine-docker download"
BUILD_CMD="SPC_USE_ARCH=aarch64 ./bin/spc-alpine-docker build"
RUNS_ON="ubuntu-latest"
;;
macos-x86_64)
DOWN_CMD="composer update --no-dev --classmap-authoritative && ./bin/spc doctor --auto-fix && ./bin/spc download"
BUILD_CMD="./bin/spc build"
RUNS_ON="macos-13"
;;
macos-aarch64)
DOWN_CMD="composer update --no-dev --classmap-authoritative && ./bin/spc doctor --auto-fix && ./bin/spc download"
BUILD_CMD="./bin/spc build"
RUNS_ON="macos-14"
;;
esac
DOWN_CMD="$DOWN_CMD --with-php=${{ inputs.php-version }} --for-extensions=${{ inputs.extensions }} --ignore-cache-sources=php-src"
BUILD_CMD="$BUILD_CMD ${{ inputs.extensions }}"
if [ -n "${{ inputs.extra-libs }}" ]; then
DOWN_CMD="$DOWN_CMD --for-libs=${{ inputs.extra-libs }}"
BUILD_CMD="$BUILD_CMD --with-libs=${{ inputs.extra-libs }}"
fi
if [ ${{ inputs.debug }} == true ]; then
DOWN_CMD="$DOWN_CMD --debug"
BUILD_CMD="$BUILD_CMD --debug"
fi
if [ ${{ inputs.prefer-pre-built }} == true ]; then
DOWN_CMD="$DOWN_CMD --prefer-pre-built"
fi
if [ ${{ inputs.build-cli }} == true ]; then
BUILD_CMD="$BUILD_CMD --build-cli"
fi
if [ ${{ inputs.build-micro }} == true ]; then
BUILD_CMD="$BUILD_CMD --build-micro"
fi
if [ ${{ inputs.build-fpm }} == true ]; then
BUILD_CMD="$BUILD_CMD --build-fpm"
fi
echo 'download='"$DOWN_CMD" >> "$GITHUB_OUTPUT"
echo 'build='"$BUILD_CMD" >> "$GITHUB_OUTPUT"
echo 'run='"$RUNS_ON" >> "$GITHUB_OUTPUT"
build:
name: "Build ${{ inputs.version }} on ${{ inputs.os }}"
runs-on: ${{ needs.define-build.outputs.run }}
needs: define-build
timeout-minutes: 240
steps:
- name: "Checkout"
uses: actions/checkout@v4
- name: "Setup PHP"
uses: shivammathur/setup-php@v2
with:
php-version: ${{ inputs.php-version }}
tools: pecl, composer
extensions: curl, openssl, mbstring
ini-values: memory_limit=-1
env:
phpts: nts
# Cache downloaded source
- id: cache-download
uses: actions/cache@v4
with:
path: downloads
key: php-dependencies-${{ inputs.os }}
- name: "Download sources"
run: ${{ needs.define-build.outputs.download }}
- name: "Build PHP"
run: ${{ needs.define-build.outputs.build }}
#- name: Setup tmate session
# if: ${{ failure() }}
# uses: mxschmitt/action-tmate@v3
# Upload cli executable
- if: ${{ inputs.build-cli == true }}
name: "Upload PHP cli SAPI"
uses: actions/upload-artifact@v4
with:
name: php-cli-${{ inputs.php-version }}-${{ inputs.os }}
path: buildroot/bin/php
# Upload micro self-extracted executable
- if: ${{ inputs.build-micro == true }}
name: "Upload PHP micro SAPI"
uses: actions/upload-artifact@v4
with:
name: php-micro-${{ inputs.php-version }}-${{ inputs.os }}
path: buildroot/bin/micro.sfx
# Upload fpm executable
- if: ${{ inputs.build-fpm == true }}
name: "Upload PHP fpm SAPI"
uses: actions/upload-artifact@v4
with:
name: php-fpm-${{ inputs.php-version }}-${{ inputs.os }}
path: buildroot/bin/php-fpm
# Upload extensions metadata
- uses: actions/upload-artifact@v4
name: "Upload License Files"
with:
name: license-files
path: buildroot/license/
- uses: actions/upload-artifact@v4
name: "Upload Build Metadata"
with:
name: build-meta
path: |
buildroot/build-extensions.json
buildroot/build-libraries.json