-
Notifications
You must be signed in to change notification settings - Fork 2
240 lines (207 loc) · 7.78 KB
/
Copy pathbuild.yaml
File metadata and controls
240 lines (207 loc) · 7.78 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
name: Build
on: [push]
permissions:
contents: write
env:
EXTENSION_NAME: mjml
jobs:
tests:
runs-on: ubuntu-24.04
strategy:
matrix:
php-version: [ "8.3", "8.5" ]
clang: [ "20" ]
steps:
- name: Checkout
uses: actions/checkout@v6
with:
submodules: recursive
- name: Cache cargo and LLVM and Clang
id: cache-llvm
uses: actions/cache@v5
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
${{ runner.temp }}/llvm-${{ matrix.clang }}
key: ${{ matrix.php-version }}-test
- name: Setup LLVM & Clang
id: clang
if: runner.os == 'Linux'
uses: KyleMayes/install-llvm-action@v2
with:
version: ${{ matrix.clang }}
directory: ${{ runner.temp }}/llvm-${{ matrix.clang }}
cached: ${{ steps.cache-llvm.outputs.cache-hit }}
- name: Configure Clang
run: |
echo "LIBCLANG_PATH=${{ runner.temp }}/llvm-${{ matrix.clang }}/lib" >> $GITHUB_ENV
echo "LLVM_VERSION=${{ steps.clang.outputs.version }}" >> $GITHUB_ENV
echo "LLVM_CONFIG_PATH=${{ runner.temp }}/llvm-${{ matrix.clang }}/bin/llvm-config" >> $GITHUB_ENV
- uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
tools: php-config
- name: Install latest Rust toolchain
run: |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
source $HOME/.cargo/env
rustup default stable
- name: Build module
run: |
phpize
./configure --enable-cargo-debug
make
- name: Run PHP Test
run: NO_INTERACTION=1 php run-tests.php -n -d extension=target/debug/lib${{ env.EXTENSION_NAME }}.so
get-win-extension-matrix:
runs-on: ubuntu-24.04
outputs:
matrix: ${{ steps.extension-matrix.outputs.matrix }}
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Get the extension matrix
id: extension-matrix
uses: php/php-windows-builder/extension-matrix@v1
with:
php-version-list: '8.1,8.2,8.3,8.4,8.5'
arch-list: 'x64'
build-windows:
needs: [tests, get-win-extension-matrix]
runs-on: windows-latest
strategy:
matrix: ${{fromJson(needs.get-win-extension-matrix.outputs.matrix)}}
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Cache cargo and LLVM and Clang
id: cache-llvm
uses: actions/cache@v5
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
${{ runner.temp }}/llvm-20
key: ${{ matrix.php-version }}-win-${{ matrix.arch }}-${{ matrix.ts }}-stable-build
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: nightly
components: rustfmt, clippy
- name: Build the extension
uses: php/php-windows-builder/extension@v1
with:
php-version: ${{ matrix.php-version }}
run-tests: 'false'
arch: ${{ matrix.arch }}
ts: ${{ matrix.ts }}
build-nix:
runs-on: ${{ matrix.os }}
needs: tests
strategy:
matrix:
clang: [ "20" ]
php-version: [ "8.1", "8.2", "8.3", "8.4" ]
target: [ aarch64-apple-darwin, x86_64-apple-darwin, x86_64-unknown-linux-gnu, x86_64-unknown-linux-musl, aarch64-unknown-linux-gnu ]
phpts: [ "nts", "ts" ]
include:
- { rust_channel: stable }
- { target: aarch64-apple-darwin, os: macos-latest }
- { target: x86_64-apple-darwin, os: macos-latest }
- { target: x86_64-unknown-linux-gnu, os: ubuntu-22.04 }
- { target: x86_64-unknown-linux-musl, os: ubuntu-22.04 }
- { target: aarch64-unknown-linux-gnu, os: ubuntu-22.04 }
exclude:
- { target: aarch64-apple-darwin, phpts: ts }
- { target: x86_64-apple-darwin, phpts: ts }
- { target: x86_64-unknown-linux-gnu, phpts: ts }
- { target: aarch64-unknown-linux-gnu, phpts: ts }
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Cache cargo and LLVM and Clang
id: cache-llvm
uses: actions/cache@v5
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
${{ runner.temp }}/llvm-${{ matrix.clang }}
key: ${{ matrix.php-version }}-${{ matrix.target }}-${{ matrix.clang }}-${{ matrix.phpts }}-${{ matrix.rust_channel }}-build
- name: Setup LLVM & Clang
id: clang
if: runner.os == 'Linux'
uses: KyleMayes/install-llvm-action@v2
with:
version: ${{ matrix.clang }}
directory: ${{ runner.temp }}/llvm-${{ matrix.clang }}
cached: ${{ steps.cache-llvm.outputs.cache-hit }}
- name: Configure Clang
if: runner.os == 'Linux'
run: |
echo "LIBCLANG_PATH=${{ runner.temp }}/llvm-${{ matrix.clang }}/lib" >> $GITHUB_ENV
echo "LLVM_VERSION=${{ steps.clang.outputs.version }}" >> $GITHUB_ENV
echo "LLVM_CONFIG_PATH=${{ runner.temp }}/llvm-${{ matrix.clang }}/bin/llvm-config" >> $GITHUB_ENV
- name: Install latest Rust toolchain
run: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain ${{ matrix.rust_channel }} --target ${{ matrix.target }}
shell: bash
- name: Setup PHP with PECL extension
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
tools: php-config
env:
phpts: ${{ matrix.phpts }}
- name: OS Specific Configuration - Linux
if: runner.os == 'Linux'
run: |
echo "OUTPUT_FILE=lib${{ env.EXTENSION_NAME }}.so" >> $GITHUB_ENV
echo "LIB_EXT=so" >> $GITHUB_ENV
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu libc6-dev-arm64-cross musl-tools musl-dev
- name: OS Specific Configuration - macOS
if: runner.os == 'macOS'
run: |
echo "OUTPUT_FILE=lib${{ env.EXTENSION_NAME }}.dylib" >> $GITHUB_ENV
echo "LIB_EXT=so" >> $GITHUB_ENV
- name: Build module
run: |
cargo build --release --target ${{ matrix.target }} --lib
- name: Rename file
run: mv target/${{ matrix.target }}/release/${{ env.OUTPUT_FILE }} target/php${{ matrix.php-version }}-${{ matrix.phpts }}-${{ matrix.target }}-${{ env.EXTENSION_NAME }}.${{ env.LIB_EXT }}
shell: bash
- uses: actions/upload-artifact@v7
with:
name: php${{ matrix.php-version }}-${{ matrix.phpts }}-${{ matrix.target }}
path: target/php${{ matrix.php-version }}-${{ matrix.phpts }}-${{ matrix.target }}-${{ env.EXTENSION_NAME }}.${{ env.LIB_EXT }}
release:
runs-on: ubuntu-24.04
needs: [build-nix, build-windows]
if: startsWith(github.ref, 'refs/tags/v') || github.event_name == 'release'
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Get Cargo Version
id: cargo_version
run: |
VERSION=$(grep '^version =' Cargo.toml | head -n 1 | sed 's/.*"\(.*\)".*/\1/')
echo "VERSION=$VERSION" >> $GITHUB_ENV
shell: bash
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
merge-multiple: 'true'
- name: Create release
uses: ncipollo/release-action@v1
with:
artifacts: "artifacts/php*"