Skip to content

Commit e1a2193

Browse files
committed
AppVeyor CI integration
We set up basic AppVeyor CI integration for building and packaging on Windows.
1 parent d15482e commit e1a2193

File tree

4 files changed

+172
-0
lines changed

4 files changed

+172
-0
lines changed

.appveyor.yml

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# general configuration
2+
version: '{branch}.{build}'
3+
4+
# environment configuration
5+
image: Visual Studio 2017
6+
clone_folder: C:\projects\php_simple_kafka_client
7+
environment:
8+
BIN_SDK_VER: 2.2.0
9+
DEP: librdkafka-1.5.3
10+
matrix:
11+
- PHP_VER: 7.3
12+
TS: 0
13+
VC: vc15
14+
ARCH: x64
15+
OPCACHE: 0
16+
- PHP_VER: 7.3
17+
TS: 1
18+
VC: vc15
19+
ARCH: x64
20+
OPCACHE: 1
21+
- PHP_VER: 7.4
22+
TS: 0
23+
VC: vc15
24+
ARCH: x64
25+
OPCACHE: 0
26+
- PHP_VER: 7.4
27+
TS: 1
28+
VC: vc15
29+
ARCH: x64
30+
OPCACHE: 1
31+
- PHP_VER: 8.0
32+
TS: 0
33+
VC: vs16
34+
ARCH: x64
35+
OPCACHE: 0
36+
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
37+
- PHP_VER: 8.0
38+
TS: 1
39+
VC: vs16
40+
ARCH: x64
41+
OPCACHE: 1
42+
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
43+
cache:
44+
- C:\build-cache -> .appveyor.yml, .appveyor\install.ps1
45+
install:
46+
- ps: .appveyor\install.ps1
47+
48+
# build configuration
49+
build_script:
50+
- ps: .appveyor\build.ps1
51+
52+
after_build:
53+
- ps: .appveyor\package.ps1

.appveyor/build.ps1

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
$ErrorActionPreference = "Stop"
2+
3+
Set-Location 'C:\projects\php_simple_kafka_client'
4+
5+
$task = New-Item 'task.bat' -Force
6+
Add-Content $task "call phpize 2>&1"
7+
Add-Content $task "call configure --with-php-build=C:\build-cache\deps --with-simple-kafka-client --enable-debug-pack 2>&1"
8+
Add-Content $task "nmake /nologo 2>&1"
9+
Add-Content $task "exit %errorlevel%"
10+
& "C:\build-cache\php-sdk-$env:BIN_SDK_VER\phpsdk-$env:VC-$env:ARCH.bat" -t $task
11+
if (-not $?) {
12+
throw "build failed with errorlevel $LastExitCode"
13+
}

.appveyor/install.ps1

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
$ErrorActionPreference = "Stop"
2+
3+
if (-not (Test-Path 'C:\build-cache')) {
4+
[void](New-Item 'C:\build-cache' -ItemType 'directory')
5+
}
6+
7+
$bname = "php-sdk-$env:BIN_SDK_VER.zip"
8+
if (-not (Test-Path "C:\build-cache\$bname")) {
9+
Invoke-WebRequest "https://github.com/Microsoft/php-sdk-binary-tools/archive/$bname" -OutFile "C:\build-cache\$bname"
10+
}
11+
$dname0 = "php-sdk-binary-tools-php-sdk-$env:BIN_SDK_VER"
12+
$dname1 = "php-sdk-$env:BIN_SDK_VER"
13+
if (-not (Test-Path "C:\build-cache\$dname1")) {
14+
Expand-Archive "C:\build-cache\$bname" 'C:\build-cache'
15+
Move-Item "C:\build-cache\$dname0" "C:\build-cache\$dname1"
16+
}
17+
18+
$gareleases = Invoke-WebRequest "https://windows.php.net/downloads/releases/releases.json" | ConvertFrom-Json
19+
$qareleases = Invoke-WebRequest "https://windows.php.net/downloads/qa/releases.json" | ConvertFrom-Json
20+
$garev = [regex]::split($gareleases.$env:PHP_VER.version, '[^\d]')[2]
21+
$qarev = [regex]::split($qareleases.$env:PHP_VER.version, '[^\d]')[2]
22+
if ($qarev -gt $garev) {
23+
$phpversion = $qareleases.$env:PHP_VER.version
24+
$phprelease = 'QA'
25+
} else {
26+
$phpversion = $gareleases.$env:PHP_VER.version
27+
$phprelease = 'GA'
28+
}
29+
30+
$ts_part = ''
31+
if ($env:TS -eq '0') {
32+
$ts_part += '-nts'
33+
}
34+
$bname = "php-devel-pack-$phpversion$ts_part-Win32-$env:VC-$env:ARCH.zip"
35+
if (-not (Test-Path "C:\build-cache\$bname")) {
36+
if ($phprelease -eq "GA") {
37+
Invoke-WebRequest "https://windows.php.net/downloads/releases/$bname" -OutFile "C:\build-cache\$bname"
38+
} else {
39+
Invoke-WebRequest "https://windows.php.net/downloads/qa/$bname" -OutFile "C:\build-cache\$bname"
40+
}
41+
}
42+
$dname0 = "php-$phpversion-devel-$env:VC-$env:ARCH"
43+
$dname1 = "php-$phpversion$ts_part-devel-$env:VC-$env:ARCH"
44+
if (-not (Test-Path "C:\build-cache\$dname1")) {
45+
Expand-Archive "C:\build-cache\$bname" 'C:\build-cache'
46+
if ($dname0 -ne $dname1) {
47+
Move-Item "C:\build-cache\$dname0" "C:\build-cache\$dname1"
48+
}
49+
}
50+
$env:PATH = "C:\build-cache\$dname1;$env:PATH"
51+
52+
$bname = "php-$phpversion$ts_part-Win32-$env:VC-$env:ARCH.zip"
53+
if (-not (Test-Path "C:\build-cache\$bname")) {
54+
if ($phprelease -eq "GA") {
55+
Invoke-WebRequest "https://windows.php.net/downloads/releases/$bname" -OutFile "C:\build-cache\$bname"
56+
} else {
57+
Invoke-WebRequest "https://windows.php.net/downloads/qa/$bname" -OutFile "C:\build-cache\$bname"
58+
}
59+
}
60+
$dname = "php-$phpversion$ts_part-$env:VC-$env:ARCH"
61+
if (-not (Test-Path "C:\build-cache\$dname")) {
62+
Expand-Archive "C:\build-cache\$bname" "C:\build-cache\$dname"
63+
}
64+
$env:PATH = "c:\build-cache\$dname;$env:PATH"
65+
66+
$bname = "$env:DEP-$env:VC-$env:ARCH.zip"
67+
if (-not (Test-Path "C:\build-cache\$bname")) {
68+
Invoke-WebRequest "http://windows.php.net/downloads/pecl/deps/$bname" -OutFile "C:\build-cache\$bname"
69+
Expand-Archive "C:\build-cache\$bname" 'C:\build-cache\deps'
70+
Copy-Item "C:\build-cache\deps\LICENSE" "C:\build-cache\deps\LICENSE.LIBRDKAFKA"
71+
}

.appveyor/package.ps1

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
$ErrorActionPreference = "Stop"
2+
3+
if ($env:TS -eq '0') {
4+
$ts_part = 'nts'
5+
} else {
6+
$ts_part = 'ts';
7+
}
8+
9+
if ($env:APPVEYOR_REPO_TAG -eq "true") {
10+
$bname = "php_simple_kafka_client-$env:APPVEYOR_REPO_TAG_NAME-$env:PHP_VER-$ts_part-$env:VC-$env:ARCH"
11+
} else {
12+
$bname = "php_simple_kafka_client-$($env:APPVEYOR_REPO_COMMIT.substring(0, 8))-$env:PHP_VER-$ts_part-$env:VC-$env:ARCH"
13+
}
14+
$zip_bname = "$bname.zip"
15+
16+
$dir = 'C:\projects\php_simple_kafka_client\';
17+
if ($env:ARCH -eq 'x64') {
18+
$dir += 'x64\'
19+
}
20+
$dir += 'Release'
21+
if ($env:TS -eq '1') {
22+
$dir += '_TS'
23+
}
24+
25+
$files = @(
26+
"$dir\php_simple_kafka_client.dll",
27+
"$dir\php_simple_kafka_client.pdb",
28+
"C:\projects\php_simple_kafka_client\LICENSE",
29+
"C:\projects\php_simple_kafka_client\README.md",
30+
"C:\build-cache\deps\bin\librdkafka.dll",
31+
"C:\build-cache\deps\bin\librdkafka.pdb",
32+
"C:\build-cache\deps\LICENSE.LIBRDKAFKA"
33+
)
34+
Compress-Archive $files "C:\$zip_bname"
35+
Push-AppveyorArtifact "C:\$zip_bname"

0 commit comments

Comments
 (0)