Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 46 additions & 7 deletions .github/workflows/_test-integrations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,17 +104,56 @@ jobs:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Install Ghostscript
run: choco install ghostscript --version 10.03.1 -y
- name: Set up php ${{ matrix.php-version }}
uses: shivammathur/setup-php@v2
env:
phpts: zts
with:
php-version: ${{ matrix.php-version }}
php-version: '${{ matrix.php-version }}'
extensions: curl, fileinfo, json, imagick
- name: Install Ghostscript
run: choco install ghostscript -y


- name: Install Ghostscript and Patch Imagick Policy
shell: powershell
run: |
$gsVersion = "10.03.1"
$gsVersionCompact = $gsVersion.Replace('.', '')
$installerUrl = "https://github.com/ArtifexSoftware/ghostpdl-downloads/releases/download/gs$gsVersionCompact/gs${gsVersionCompact}w64.exe"
$downloadPath = "$env:TEMP\gs_installer.exe"
$extractDir = "C:\gs"

Write-Host "Downloading and Extracting Ghostscript..."
Invoke-WebRequest -Uri $installerUrl -OutFile $downloadPath
7z x $downloadPath -o"$extractDir" -y | Out-Null

$binDir = (Get-ChildItem -Path $extractDir -Recurse -Filter "gswin64c.exe").Directory.FullName
$libDir = (Get-ChildItem -Path $extractDir -Recurse -Filter "gs_init.ps").Directory.FullName
$dllPath = (Get-ChildItem -Path $extractDir -Recurse -Filter "gsdll64.dll").FullName
$resourceDir = (Get-ChildItem -Path $extractDir -Recurse -Filter "Init" | Where-Object {$_.Parent.Name -eq "Resource"}).Parent.FullName

Write-Host "Creating gs.exe for generic shell commands..."
Copy-Item -Path "$binDir\gswin64c.exe" -Destination "$binDir\gs.exe"

Write-Host "Writing Registry Keys for PHP Imagick..."
$registryPath = "HKLM:\SOFTWARE\GPL Ghostscript\$gsVersion"
New-Item -Path $registryPath -Force | Out-Null
New-ItemProperty -Path $registryPath -Name "GS_DLL" -Value $dllPath -PropertyType String -Force | Out-Null

$gsLibStr = "$libDir;$resourceDir\Init;$resourceDir\Font"
New-ItemProperty -Path $registryPath -Name "GS_LIB" -Value $gsLibStr -PropertyType String -Force | Out-Null

Write-Host "Adding Ghostscript to GITHUB_ENV and GITHUB_PATH..."
Add-Content -Path $env:GITHUB_ENV -Value "GS_PROG=$binDir\gs.exe"
Add-Content -Path $env:GITHUB_PATH -Value $binDir
Add-Content -Path $env:GITHUB_PATH -Value $libDir

Write-Host "Patching ImageMagick policy.xml on Windows..."
$policyFiles = Get-ChildItem -Path C:\tools\php -Filter policy.xml -Recurse -ErrorAction SilentlyContinue

foreach ($file in $policyFiles) {
Write-Host "Patching PDF rights in: $($file.FullName)"
$content = Get-Content $file.FullName
$content = $content -replace 'rights="none" pattern="PDF"', 'rights="read|write" pattern="PDF"'
Set-Content -Path $file.FullName -Value $content
}
- uses: ramsey/composer-install@v2
- name: Unit testing with phpunit
run: |
Expand Down
55 changes: 45 additions & 10 deletions .github/workflows/_test-units.yml
Original file line number Diff line number Diff line change
Expand Up @@ -181,20 +181,55 @@ jobs:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Install Ghostscript
run: choco install ghostscript --version 10.04.0 -y
- name: Create Ghostscript alias
run: |
New-Item -ItemType SymbolicLink -Path "C:\Windows\gs.exe" -Target "C:\Program Files\gs\gs10.04.0\bin\gswin64c.exe"
New-Item -ItemType SymbolicLink -Path "C:\Windows\gs" -Target "C:\Program Files\gs\gs10.04.0\bin\gswin64c.exe"
shell: powershell

- name: Set up php ${{ matrix.php-version }}
uses: shivammathur/setup-php@v2
env:
phpts: zts
with:
php-version: ${{ matrix.php-version }}
php-version: '${{ matrix.php-version }}'
extensions: curl, fileinfo, json, imagick
- name: Install Ghostscript and Patch Imagick Policy
shell: powershell
run: |
$gsVersion = "10.03.1"
$gsVersionCompact = $gsVersion.Replace('.', '')
$installerUrl = "https://github.com/ArtifexSoftware/ghostpdl-downloads/releases/download/gs$gsVersionCompact/gs${gsVersionCompact}w64.exe"
$downloadPath = "$env:TEMP\gs_installer.exe"
$extractDir = "C:\gs"

Write-Host "Downloading and Extracting Ghostscript..."
Invoke-WebRequest -Uri $installerUrl -OutFile $downloadPath
7z x $downloadPath -o"$extractDir" -y | Out-Null

$binDir = (Get-ChildItem -Path $extractDir -Recurse -Filter "gswin64c.exe").Directory.FullName
$libDir = (Get-ChildItem -Path $extractDir -Recurse -Filter "gs_init.ps").Directory.FullName
$dllPath = (Get-ChildItem -Path $extractDir -Recurse -Filter "gsdll64.dll").FullName
$resourceDir = (Get-ChildItem -Path $extractDir -Recurse -Filter "Init" | Where-Object {$_.Parent.Name -eq "Resource"}).Parent.FullName

Write-Host "Creating gs.exe for generic shell commands..."
Copy-Item -Path "$binDir\gswin64c.exe" -Destination "$binDir\gs.exe"

Write-Host "Writing Registry Keys for PHP Imagick..."
$registryPath = "HKLM:\SOFTWARE\GPL Ghostscript\$gsVersion"
New-Item -Path $registryPath -Force | Out-Null
New-ItemProperty -Path $registryPath -Name "GS_DLL" -Value $dllPath -PropertyType String -Force | Out-Null

$gsLibStr = "$libDir;$resourceDir\Init;$resourceDir\Font"
New-ItemProperty -Path $registryPath -Name "GS_LIB" -Value $gsLibStr -PropertyType String -Force | Out-Null

Write-Host "Adding Ghostscript to GITHUB_ENV and GITHUB_PATH..."
Add-Content -Path $env:GITHUB_ENV -Value "GS_PROG=$binDir\gs.exe"
Add-Content -Path $env:GITHUB_PATH -Value $binDir
Add-Content -Path $env:GITHUB_PATH -Value $libDir

Write-Host "Patching ImageMagick policy.xml on Windows..."
$policyFiles = Get-ChildItem -Path C:\tools\php -Filter policy.xml -Recurse -ErrorAction SilentlyContinue

foreach ($file in $policyFiles) {
Write-Host "Patching PDF rights in: $($file.FullName)"
$content = Get-Content $file.FullName
$content = $content -replace 'rights="none" pattern="PDF"', 'rights="read|write" pattern="PDF"'
Set-Content -Path $file.FullName -Value $content
}
- uses: ramsey/composer-install@v3
- name: Unit testing with phpunit
env:
Expand Down
Loading