Skip to content

Commit 67e2548

Browse files
committed
Add example workflows and improve the example in README
1 parent d172b16 commit 67e2548

File tree

5 files changed

+151
-3
lines changed

5 files changed

+151
-3
lines changed

.github/workflows/extension.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# Caution: This workflow is internal to the php-windows-builder repository.
2+
# Do not copy this workflow to your repository.
3+
# Instead, refer to the workflows in the examples/ directory.
4+
15
name: Build PHP Extension
26
run-name: Build PHP Extension ${{ inputs.extension-url }}, ${{ inputs.extension-ref }}
37
on:

.github/workflows/pecl.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# Caution: This workflow is internal to the php-windows-builder repository.
2+
# Do not copy this workflow to your repository.
3+
# Instead, refer to the workflows in the examples/ directory.
4+
15
name: Build PHP Extension From PECL
26
run-name: Build PHP Extension ${{ inputs.extension-url }}, ${{ inputs.extension-ref }}
37
on:

README.md

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,10 @@ Upload the artifacts to a release.
188188
```yaml
189189
name: Build extension
190190
on:
191+
# When a new release is created, we can build, and upload the DLLs to it.
191192
release:
192-
types: [published]
193+
types: [created]
194+
# push: # Uncomment this to run on push to a branch
193195
# create: # Uncomment this to run on tag/branch creation
194196
# pull_request: # Uncomment this to run on pull requests
195197
@@ -199,30 +201,41 @@ on:
199201
# contents: write
200202
201203
jobs:
204+
# This job generates a matrix of PHP versions, architectures, and thread safety options
205+
# This is done by reading the constraints from composer.json or the package.xml file.
206+
# Please refer to https://github.com/php/php-windows-builder#get-the-job-matrix-to-build-a-php-extension
202207
get-extension-matrix:
203208
runs-on: ubuntu-latest
204209
outputs:
205210
matrix: ${{ steps.extension-matrix.outputs.matrix }}
206211
steps:
207212
- name: Checkout
208-
uses: actions/checkout@v4
213+
uses: actions/checkout@v5
214+
209215
- name: Get the extension matrix
210216
id: extension-matrix
211217
uses: php/php-windows-builder/extension-matrix@v1
218+
219+
# This job builds the extension on Windows using the matrix generated from the previous job.
212220
build:
213221
needs: get-extension-matrix
214222
runs-on: ${{ matrix.os }}
215223
strategy:
216224
matrix: ${{fromJson(needs.get-extension-matrix.outputs.matrix)}}
217225
steps:
218226
- name: Checkout
219-
uses: actions/checkout@v4
227+
uses: actions/checkout@v5
228+
220229
- name: Build the extension
221230
uses: php/php-windows-builder/extension@v1
222231
with:
232+
# Always specify the php-version, arch, and ts as they are required inputs.
233+
# Please refer to https://github.com/php/php-windows-builder#build-a-php-extension
223234
php-version: ${{ matrix.php-version }}
224235
arch: ${{ matrix.arch }}
225236
ts: ${{ matrix.ts }}
237+
238+
# This job uploads the built artifacts to the GitHub release.
226239
release:
227240
runs-on: ubuntu-latest
228241
needs: build
@@ -235,6 +248,8 @@ jobs:
235248
token: ${{ secrets.GITHUB_TOKEN }}
236249
```
237250

251+
For more example workflows, please refer to the [examples](./examples) directory.
252+
238253
## Local Setup
239254

240255
### PHP

examples/imagick.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# This workflow assumes that it is in a repository that contains the imagick extension source code.
2+
name: Build and Test Imagick on Windows
3+
on:
4+
push:
5+
pull_request:
6+
# When a new release is created, we can build, and upload the DLLs to it.
7+
release:
8+
types: [created]
9+
jobs:
10+
# This job generates a matrix of PHP versions, architectures, and thread safety options
11+
# This is done by reading the constraints from composer.json or the package.xml file.
12+
# Please refer to https://github.com/php/php-windows-builder#get-the-job-matrix-to-build-a-php-extension
13+
get-extension-matrix:
14+
runs-on: ubuntu-latest
15+
outputs:
16+
matrix: ${{ steps.extension-matrix.outputs.matrix }}
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v5
20+
21+
- name: Get the extension matrix
22+
id: extension-matrix
23+
uses: php/php-windows-builder/extension-matrix@v1
24+
25+
# This job builds the extension on Windows using the matrix generated from the previous job.
26+
build:
27+
needs: get-extension-matrix
28+
runs-on: ${{ matrix.os }}
29+
strategy:
30+
matrix: ${{fromJson(needs.get-extension-matrix.outputs.matrix)}}
31+
steps:
32+
- name: Checkout
33+
uses: actions/checkout@v5
34+
35+
- name: Build the extension
36+
uses: php/php-windows-builder/extension@v1
37+
with:
38+
# Always specify the php-version, arch, and ts as they are required inputs.
39+
# Please refer to https://github.com/php/php-windows-builder#build-a-php-extension
40+
php-version: ${{ matrix.php-version }}
41+
arch: ${{ matrix.arch }}
42+
ts: ${{ matrix.ts }}
43+
44+
# Refer to your config.w32 file to find the libraries you need.
45+
# Refer to the following directories to see if we support the libraries you need.
46+
# https://downloads.php.net/~windows/pecl/deps
47+
# https://downloads.php.net/~windows/php-sdk/deps
48+
libs: ImageMagick-7
49+
50+
# This job uploads the built artifacts to the GitHub release.
51+
release:
52+
runs-on: ubuntu-latest
53+
needs: build
54+
if: ${{ github.event_name == 'release' }}
55+
steps:
56+
- name: Upload artifact to the release
57+
uses: php/php-windows-builder/release@v1
58+
with:
59+
release: ${{ github.event.release.tag_name }}
60+
token: ${{ secrets.GITHUB_TOKEN }}

examples/xdebug.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# This workflow assumes that it is in a repository that contains the Xdebug extension source code.
2+
name: Build and Test Xdebug on Windows
3+
on:
4+
push:
5+
pull_request:
6+
# When a new release is created, we can build, and upload the DLLs to it.
7+
release:
8+
types: [created]
9+
jobs:
10+
# This job generates a matrix of PHP versions, architectures, and thread safety options
11+
# This is done by reading the constraints from composer.json or the package.xml file.
12+
# Please refer to https://github.com/php/php-windows-builder#get-the-job-matrix-to-build-a-php-extension
13+
get-extension-matrix:
14+
runs-on: ubuntu-latest
15+
outputs:
16+
matrix: ${{ steps.extension-matrix.outputs.matrix }}
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v5
20+
21+
- name: Get the extension matrix
22+
id: extension-matrix
23+
uses: php/php-windows-builder/extension-matrix@v1
24+
25+
# This job builds the extension on Windows using the matrix generated from the previous job.
26+
build:
27+
needs: get-extension-matrix
28+
runs-on: ${{ matrix.os }}
29+
strategy:
30+
matrix: ${{fromJson(needs.get-extension-matrix.outputs.matrix)}}
31+
steps:
32+
- name: Checkout
33+
uses: actions/checkout@v5
34+
35+
- name: Build the extension
36+
uses: php/php-windows-builder/extension@v1
37+
with:
38+
# Always specify the php-version, arch, and ts as they are required inputs.
39+
# Please refer to https://github.com/php/php-windows-builder#build-a-php-extension
40+
php-version: ${{ matrix.php-version }}
41+
arch: ${{ matrix.arch }}
42+
ts: ${{ matrix.ts }}
43+
44+
# Refer to your config.w32 file to find the libraries you need.
45+
# Refer to the following directories to see if we support the libraries you need.
46+
# https://downloads.php.net/~windows/pecl/deps
47+
# https://downloads.php.net/~windows/php-sdk/deps
48+
libs: zlib
49+
50+
# Refer to your config.w32 file to find the arguments you need to pass to the ./configure step.
51+
# It will add the --enable-<extension> or --with-<extension> argument if configured in the composer.json file.
52+
# In this case, we need to add the --with-xdebug argument manually.
53+
args: --with-xdebug
54+
55+
# This job uploads the built artifacts to the GitHub release.
56+
release:
57+
runs-on: ubuntu-latest
58+
needs: build
59+
if: ${{ github.event_name == 'release' }}
60+
steps:
61+
- name: Upload artifact to the release
62+
uses: php/php-windows-builder/release@v1
63+
with:
64+
release: ${{ github.event.release.tag_name }}
65+
token: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)