Skip to content

Commit fb0f366

Browse files
committed
Add GHA, to also build Windows binaries
1 parent afb7052 commit fb0f366

1 file changed

Lines changed: 90 additions & 0 deletions

File tree

.github/workflows/build.yml

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
name: Build
2+
3+
on:
4+
push:
5+
branches: [master]
6+
pull_request:
7+
release:
8+
types: [created]
9+
create:
10+
11+
jobs:
12+
windows:
13+
runs-on: windows-latest
14+
name: "Windows: Build and test"
15+
defaults:
16+
run:
17+
shell: cmd
18+
strategy:
19+
fail-fast: false
20+
matrix:
21+
php: ["7.3", "7.4", "8.0", "8.1", "8.2"]
22+
arch: [x86, x64]
23+
ts: [nts, ts]
24+
experimental: [false]
25+
steps:
26+
- name: Checkout Repository
27+
uses: actions/checkout@v3
28+
- name: Extract Version
29+
shell: powershell
30+
run: |
31+
chcp 65001
32+
$r = Select-String -Path php_mcrypt.h -Pattern 'PHP_MCRYPT_VERSION\s+"(.*)"'
33+
$s = $r.Matches[0].Groups[1]
34+
echo "$s"
35+
$extension_version = 'EXTENSION_VERSION=' + $s
36+
echo $extension_version >> $env:GITHUB_ENV
37+
- name: Setup PHP
38+
id: setup-php
39+
uses: cmb69/setup-php-sdk@v0.7
40+
with:
41+
version: ${{matrix.php}}
42+
arch: ${{matrix.arch}}
43+
ts: ${{matrix.ts}}
44+
- name: Enable Developer Command Prompt
45+
uses: ilammy/msvc-dev-cmd@v1
46+
with:
47+
arch: ${{matrix.arch}}
48+
toolset: ${{steps.setup-php.outputs.toolset}}
49+
- name: Generate Build Files
50+
run: phpize
51+
- name: Configure Build
52+
run: configure --enable-mcrypt --with-prefix=${{steps.setup-php.outputs.prefix}}
53+
- name: Build
54+
run: nmake
55+
- name: Define Module Env
56+
shell: powershell
57+
run: |
58+
chcp 65001
59+
60+
$dir = (Get-Location).Path + '\'
61+
if ('x64' -eq '${{matrix.arch}}') { $dir = $dir + 'x64\' }
62+
$dir = $dir + 'Release'
63+
if ('ts' -eq '${{matrix.ts}}') { $dir = $dir + '_TS' }
64+
65+
$artifact_name = 'php_mcrypt-${{env.EXTENSION_VERSION}}-${{matrix.php}}'
66+
67+
if ('7.2' -eq '${{matrix.php}}') { $artifact_name = $artifact_name + '-vc15' }
68+
if ('7.3' -eq '${{matrix.php}}') { $artifact_name = $artifact_name + '-vc15' }
69+
if ('7.4' -eq '${{matrix.php}}') { $artifact_name = $artifact_name + '-vc15' }
70+
if ('8.0' -eq '${{matrix.php}}') { $artifact_name = $artifact_name + '-vs16' }
71+
if ('8.1' -eq '${{matrix.php}}') { $artifact_name = $artifact_name + '-vs16' }
72+
if ('8.2' -eq '${{matrix.php}}') { $artifact_name = $artifact_name + '-vs16' }
73+
74+
if ('nts' -eq '${{matrix.ts}}') { $artifact_name = $artifact_name + '-nts' }
75+
if ('x64' -eq '${{matrix.arch}}') { $artifact_name = $artifact_name + '-x86_64' }
76+
77+
$extension_artifact_name = "ARTIFACT_NAME=" + $artifact_name
78+
echo $extension_artifact_name >> $env:GITHUB_ENV
79+
80+
$from = $dir + '\php_mcrypt.dll'
81+
$to = $dir + '\' + $artifact_name + ".dll"
82+
Copy-Item $from -Destination $to
83+
$extension_artifact = "ARTIFACT=" + $to
84+
echo $extension_artifact >> $env:GITHUB_ENV
85+
86+
- name: Upload artifacts
87+
uses: actions/upload-artifact@v3
88+
with:
89+
name: ${{env.ARTIFACT_NAME}}
90+
path: ${{env.ARTIFACT}}

0 commit comments

Comments
 (0)