Skip to content

releases

releases #80

Workflow file for this run

name: releases
on:
workflow_dispatch:
inputs:
ref:
description: 'Using Swow commit'
required: false
push:
tags:
- 'v*'
env:
SWOW_HAVE_SSL: 1
SWOW_HAVE_CURL: 1
SKIP_SWOW_SOCKET_WRITE_TIMEOUT_TEST: 1 # FIXME: On Windows releases CI environment, the test will fail (dead loop)
jobs:
builddlls:
# this name is used after, change it with cautious
name: Build dll for PHP-${{ matrix.php-version }}-${{ matrix.arch }}-${{ (matrix.ts == '0') && 'N' || '' }}TS-${{ (matrix.image == 'windows-2019') && 'VS16' || 'VS17' }}
runs-on: ${{ matrix.image }}
strategy:
fail-fast: false
matrix:
php-version: ["8.3", "8.2", "8.1", "8.0"]
arch: ["x64"]
ts: ["0", "1"]
image: [ "windows-2019" ]
include:
- php-version: "8.4"
arch: "x64"
ts: "0"
image: "windows-2022"
- php-version: "8.4"
arch: "x64"
ts: "1"
image: "windows-2022"
max-parallel: 10
outputs:
ref: ${{ steps.getref.outputs.ref }}
env:
deps: openssl,libcurl,libssh2,zlib,nghttp2,libpq
tools_path: C:\tools\phpdev
# old naming style php_swow-php8.1-x64-ts-VS16.dll
# dllname: "php_swow-php${{ matrix.php-version }}-${{ matrix.arch }}-${{ (matrix.ts == '0') && 'n' || '' }}ts-${{ (matrix.image == 'windows-2019') && 'VS16' || 'VS17' }}"
# PIE compatible naming style php_swow-v1.6.0-8.4-ts-vs17.dll
dllname: "php_swow-${{ github.ref_type == 'tag' && github.ref_name || github.sha }}-${{ matrix.php-version }}-${{ (matrix.ts == '0') && 'n' || '' }}ts-${{ (matrix.image == 'windows-2019') && 'vs16' || 'vs17' }}-${{ matrix.arch }}"
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ (github.event.inputs && github.event.inputs.ref) || github.ref }}
- name: Get git commit ref hash
id: getref
shell: powershell
run: |
$ref = git rev-parse HEAD
Write-Output "ref=$ref" | Out-File "${env:GITHUB_OUTPUT}" -Append
- name: Prepare caches
id: cacheprepare
env:
UNIX_COLOR: 1
run: |
. "./.github/workflows/winext/utils.ps1" -ToolName "cacheprepare" -MaxTry 3
$phpver = "${{ matrix.php-version }}"
if ($phpver.Equals("8.4")) {
$PhpVCVer = "VS17"
} elseif ($phpver.Equals("8.3") -Or $phpver.Equals("8.2") -Or $phpver.Equals("8.1") -Or $phpver.Equals("8.0")) {
$PhpVCVer = "VS16"
} else {
Write-Host "::error::Bad version"
exit 1
}
function phpsdkver {
$headers = @{
"accept"="application/vnd.github.v3+json";
"content-type"="application/json";
"authorization"="Bearer ${{ secrets.GITHUB_TOKEN }}";
}
$info = fetchjson -Uri "https://api.github.com/repos/php/php-sdk-binary-tools/git/ref/heads/master" -Headers $headers
if (!$info) {
warn "Cannot fetch php-sdk-binary-tools info from api.github.com"
} else {
$ver = $info."object"."sha"
Write-Output "phpsdkver=$ver" | Out-File "${env:GITHUB_OUTPUT}" -Append
}
}
info "Using $PhpVCVer"
$ret = 1
phpsdkver
./.github/workflows/winext/getphp.ps1 `
-PhpVer ${{ matrix.php-version }} `
-PhpArch ${{ matrix.arch }} `
-PhpVCVer $PhpVCVer `
-PhpTs ${{ matrix.ts }} `
-DryRun 1 &&
./.github/workflows/winext/devpack.ps1 `
-PhpVer ${{ matrix.php-version }} `
-PhpArch ${{ matrix.arch }} `
-PhpVCVer $PhpVCVer `
-PhpTs ${{ matrix.ts }} `
-DryRun 1 &&
./.github/workflows/winext/deps.ps1 `
${{ env.deps }} `
-DryRun 1 &&
($ret = 0 | Out-Null)
exit $ret
- name: Cache build environments
uses: actions/cache@v4
with:
# this should be ok, but there's a bug, excluding not work properly
# see https://github.com/actions/cache/issues/494
# see https://github.com/actions/toolkit/issues/713
# so we must remove dll and ini before
path: |
${{ env.tools_path }}
!${{ env.tools_path }}\php\ext\php_swow.dll
!${{ env.tools_path }}\php\php.ini
key: buildenv-v1-${{ matrix.arch }}-${{ matrix.ts }}-${{ steps.cacheprepare.outputs.php-version }}-${{ steps.cacheprepare.outputs.devpackver }}-${{ steps.cacheprepare.outputs.downloadeddeps }}-${{ steps.cacheprepare.outputs.phpsdkver }}
- name: Build Swow extension
id: ext-build
uses: ./.github/workflows/winext
with:
ext-path: ./ext
tools-path: ${{ env.tools_path }}
ext-name: swow
deps: ${{ env.deps }}
phpver: ${{ matrix.php-version }}
phpts: ${{ matrix.ts }}
phparch: ${{ matrix.arch }}
install: "0"
conf-args: "--enable-swow-ssl --enable-swow-curl --enable-swow-pdo-pgsql --enable-debug-pack"
- name: Prepare php for test
id: php-inst
continue-on-error: true
shell: powershell
env:
UNIX_COLOR: "1"
run: |
Write-Host "::group::Fetching php from https://downloads.php.net/~windows"
.\.github\workflows\winext\getphp.ps1 `
-PhpVer "${{ matrix.php-version }}" `
-PhpVCVer "${{ steps.ext-build.outputs.vcver }}" `
-PhpTs ${{ matrix.ts }}
$ret = $lastexitcode
Write-Host "::endgroup::"
if( 0 -Ne $ret ){
exit 1
}
Write-Host "::group::Set cafile for cURL and OpenSSL"
.\.github\workflows\winext\cafile.ps1
Write-Host "::endgroup::"
Write-Host "::group::Installing swow"
Copy-Item ext\${{ matrix.arch }}\Release${{ matrix.ts == 1 && '_TS' || '' }}\php_swow.dll ${{ env.tools_path }}\php\ext\
"extension_dir=C:\tools\phpdev\php\ext`nzend_extension=opcache`nextension=curl`nextension=openssl`nextension=pdo_pgsql`nextension=swow`n" | Out-File -Append ${{ env.tools_path }}\php\php.ini -Encoding ASCII # for no BOM
php --ri swow
# FIXME: we used `& C:\tools\phpdev\php\php.exe C:\tools\php\composer.phar test-extension` before,
# GitHub actions have strange failures on Windows release builds,
# we haven't found the reason why the program suddenly exited with 0 under composer.
- name: Run extension tests
shell: pwsh
id: ext-test
continue-on-error: true
if: steps.php-inst.outcome == 'success'
env:
UNIX_COLOR: "1"
run: |
& "${env:PGBIN}\initdb.exe" --locale=C -E UTF-8 -U postgres "C:\pgsqldata"
& "${env:PGBIN}\pg_ctl.exe" -D "C:\pgsqldata" start
${env:TEST_SWOW_POSTGRESQL} = "1"
${env:TEST_PHP_EXECUTABLE} = "C:\tools\phpdev\php\php.exe"
Set-Location ext
& C:\tools\phpdev\php\php.exe run-tests.php -P --show-diff --show-slow 1000 --set-timeout 30 --color
$ret = $lastexitcode
Write-Host "exit code $ret"
if( 0 -Ne $ret ){
exit 1
}
- name: Generate information about this dll
shell: powershell
run: |
$fn = "${{ env.dllname }}.dll"
Copy-Item ext\${{ matrix.arch }}\Release${{ matrix.ts == 1 && '_TS' || '' }}\php_swow.dll $fn
Copy-Item ext\${{ matrix.arch }}\Release${{ matrix.ts == 1 && '_TS' || '' }}\php_swow.pdb "${{ env.dllname }}.pdb"
@{
"name" = $fn;
"size" = (Get-Item $fn).Length;
"hash" = (Get-FileHash -Algorithm SHA256 $fn).Hash;
"result" = "${{ steps.ext-test.outcome }}";
"runid" = "${{ github.run_id }}";
"jobname" = "PHP-${{ matrix.php-version }}-${{ matrix.arch }}-${{ (matrix.ts == '0') && 'N' || '' }}TS-${{ (matrix.image == 'windows-2019') && 'VS16' || 'VS17' }}";
} | ConvertTo-Json -Compress | Out-File "${fn}.json" -Encoding ASCII # for no BOM
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
# see https://github.com/actions/upload-artifact/blob/main/docs/MIGRATION.md#multiple-uploads-to-the-same-named-artifact
name: "${{ env.dllname }}-${{ steps.getref.outputs.ref }}"
path: |
LICENSE
LICENSES.full
${{ env.dllname }}.dll
${{ env.dllname }}.pdb
${{ env.dllname }}.dll.json
# see notes at cache step
# TODO: remove this step when upstream fixed the bug
- name: Remove ini and dll to avoid them being cached
shell: powershell
run: |
Remove-Item ${{ env.tools_path }}\php\ext\php_swow.dll
Remove-Item ${{ env.tools_path }}\php\php.ini
mergedlls:
name: Merge DLLs
runs-on: windows-2019
needs: builddlls
steps:
- name: Merge Artifacts
uses: actions/upload-artifact/merge@v4
with:
name: all-dlls
pattern: php_swow-*
uploaddlls:
name: Upload DLLs
if: ${{ github.event_name == 'push' }}
needs:
- mergedlls
runs-on: windows-2019
permissions:
id-token: write
contents: write
attestations: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Create Release
id: create_release
run: |
.\.github\workflows\winext\release.ps1 `
-Repo "${{ github.repository }}" `
-Token "${{ secrets.GITHUB_TOKEN }}" `
-TagName "${{ github.ref }}".Split("/")[-1] `
-prerelease $true
- name: Fetch artifact
uses: actions/download-artifact@v4
with:
name: all-dlls
path: .
- name: Attestation
id: attest
uses: actions/attest-build-provenance@v1
with:
subject-path: |
php_swow-*.dll
php_swow-*.pdb
- name: Upload all dlls
shell: powershell
env:
UNIX_COLOR: "1"
run: |
.\.github\workflows\winext\uploader.ps1 `
-RelId "${{ steps.create_release.outputs.id }}" `
-Repo "${{ github.repository }}" `
-Token "${{ github.token }}" `
-AttestationBundle "${{ steps.attest.outputs.bundle-path }}"