Skip to content

Commit 26bc929

Browse files
committed
Simplify Windows builds
* Create packages for Windows in package workflow * Extract and reuse Windows build workflow * Don't create artifacts when not necessary
1 parent 5ef1c98 commit 26bc929

File tree

4 files changed

+92
-70
lines changed

4 files changed

+92
-70
lines changed

.github/workflows/build-package-files.yml renamed to .github/workflows/package-release.yml

Lines changed: 57 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: "Build package files"
1+
name: "Package Release"
22

33
on:
44
push:
@@ -10,7 +10,7 @@ on:
1010

1111
jobs:
1212
build-pecl:
13-
name: "Create release package"
13+
name: "Create PECL package"
1414
runs-on: "ubuntu-latest"
1515

1616
steps:
@@ -59,3 +59,58 @@ jobs:
5959
continue-on-error: true
6060
env:
6161
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
62+
63+
build-windows:
64+
name: "Create Windows package"
65+
runs-on: windows-2022
66+
defaults:
67+
run:
68+
shell: cmd
69+
70+
strategy:
71+
fail-fast: false
72+
matrix:
73+
# Note: keep this in sync with the Windows matrix in windows-tests.yml
74+
php: [ "7.4", "8.0", "8.1", "8.2", "8.3" ]
75+
arch: [ x64, x86 ]
76+
ts: [ ts, nts ]
77+
78+
steps:
79+
- uses: actions/checkout@v4
80+
with:
81+
fetch-depth: 2
82+
submodules: true
83+
84+
- name: "Build Driver"
85+
id: build-driver
86+
uses: ./.github/workflows/windows/build
87+
with:
88+
version: ${{ matrix.php }}
89+
arch: ${{ matrix.arch }}
90+
ts: ${{ matrix.ts }}
91+
92+
- name: "Copy DLL and PDB files to CWD"
93+
run: |
94+
cp %BUILD_DIR%\php_mongodb.dll .
95+
cp %BUILD_DIR%\php_mongodb.pdb .
96+
env:
97+
BUILD_DIR: ${{ steps.build-driver.outputs.build-dir }}
98+
99+
- name: "Upload DLL and PDB files as build artifacts"
100+
uses: actions/upload-artifact@v4
101+
with:
102+
name: php_mongodb-${{ github.ref_name }}-${{ matrix.php }}-${{ matrix.ts }}-${{ matrix.arch }}
103+
path: |
104+
php_mongodb.dll
105+
php_mongodb.pdb
106+
retention-days: 3
107+
108+
- name: "Create and upload release artifact"
109+
if: ${{ github.ref_type == 'tag' }}
110+
run: |
111+
ARCHIVE=php_mongodb-${{ github.ref_name }}-${{ matrix.php }}-${{ matrix.ts }}-${{ matrix.arch }}.zip
112+
zip $ARCHIVE php_mongodb.dll php_mongodb.pdb CREDITS CONTRIBUTING.md LICENSE README.md THIRD_PARTY_NOTICES
113+
gh release upload ${{ github.ref_name }} $ARCHIVE
114+
continue-on-error: true
115+
env:
116+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

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

Lines changed: 0 additions & 37 deletions
This file was deleted.

.github/workflows/windows-tests.yml

Lines changed: 5 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ on:
77
- "master"
88
- "feature/*"
99
push:
10-
tags:
11-
- "*"
1210
branches:
1311
- "v*.*"
1412
- "master"
@@ -36,50 +34,26 @@ jobs:
3634
fetch-depth: 2
3735
submodules: true
3836

39-
- name: Prepare build environment
40-
id: prepare-build
41-
uses: ./.github/workflows/windows/prepare-build
37+
- name: "Build Driver"
38+
id: build-driver
39+
uses: ./.github/workflows/windows/build
4240
with:
4341
version: ${{ matrix.php }}
4442
arch: ${{ matrix.arch }}
4543
ts: ${{ matrix.ts }}
4644

47-
- name: Build driver
48-
run: nmake /nologo
49-
5045
- name: Cache build artifacts for subsequent builds
5146
id: cache-build-artifacts
5247
uses: actions/cache/save@v4
5348
with:
5449
key: ${{ github.sha }}-${{ matrix.php }}-${{ matrix.ts }}-${{ matrix.arch }}
5550
path: |
56-
${{ steps.prepare-build.outputs.build-dir }}\php_mongodb.dll
57-
${{ steps.prepare-build.outputs.build-dir }}\php_mongodb.pdb
58-
59-
- name: Copy DLL and PDB files to CWD
60-
if: ${{ github.event_name == 'push' }}
61-
run: |
62-
cp .github/workflows/get-build-dir.bat .
63-
for /F "usebackq tokens=*" %%i in (`get-build-dir.bat`) do set BUILD_DIR=%%i
64-
echo BUILD_DIR=%BUILD_DIR%
65-
cp %BUILD_DIR%\php_mongodb.dll .
66-
cp %BUILD_DIR%\php_mongodb.pdb .
67-
68-
- name: Upload DLL and PDB files as build artifacts
69-
if: ${{ github.event_name == 'push' }}
70-
uses: actions/upload-artifact@v4
71-
with:
72-
name: php_mongodb-${{ github.sha }}-${{ matrix.php }}-${{ matrix.ts }}-${{ matrix.arch }}
73-
path: |
74-
php_mongodb.dll
75-
php_mongodb.pdb
76-
retention-days: 3
51+
${{ steps.build-driver.outputs.build-dir }}\php_mongodb.dll
52+
${{ steps.build-driver.outputs.build-dir }}\php_mongodb.pdb
7753
7854
test:
7955
name: "Windows Tests"
8056
runs-on: windows-2022
81-
# Run tests only when pushing to a branch. When pushing a tag, we're only interested in building the DLLs.
82-
if: ${{ github.ref_type == 'branch' }}
8357
needs: build
8458
defaults:
8559
run:
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: "Build DLL files for Windows"
2+
description: "Prepares the PHP build environment for the MongoDB driver"
3+
inputs:
4+
version:
5+
description: "PHP version to build for"
6+
required: true
7+
arch:
8+
description: "The architecture to build for (x64 or x86)"
9+
required: true
10+
ts:
11+
description: "Thread-safety (nts or ts)"
12+
required: true
13+
outputs:
14+
build-dir:
15+
description: "The build directory to be used"
16+
value: ${{ steps.prepare-build-env.outputs.build-dir }}
17+
runs:
18+
using: composite
19+
steps:
20+
- name: Prepare build environment
21+
id: prepare-build-env
22+
uses: ./.github/workflows/windows/prepare-build
23+
with:
24+
version: ${{ inputs.version }}
25+
arch: ${{ inputs.arch }}
26+
ts: ${{ inputs.ts }}
27+
28+
- name: Build driver
29+
shell: cmd
30+
run: nmake /nologo

0 commit comments

Comments
 (0)