[PHP-WEBMASTER] [web-downloads] main: Add support to upload php libraries without updating series files

Author: Shivam Mathur (shivammathur)
Date: 2026-04-10T16:41:29+05:30

Commit: Add support to upload php libraries without updating series files · php/web-downloads@e2a2504 · GitHub
Raw diff: https://github.com/php/web-downloads/commit/e2a250451e9e8551b16f3922644ee7a35ebe6f70.diff

Add support to upload php libraries without updating series files

Changed paths:
  M .github/workflows/winlibs.yml
  M API.md
  M src/Console/Command/WinlibsCommand.php
  M src/Http/Controllers/WinlibsController.php
  M tests/Console/Command/WinlibsCommandTest.php

Diff:

diff --git a/.github/workflows/winlibs.yml b/.github/workflows/winlibs.yml
index e850dd8..aa576ba 100644
--- a/.github/workflows/winlibs.yml
+++ b/.github/workflows/winlibs.yml
@@ -28,6 +28,10 @@ on:
       stability:
         description: 'Stability'
         required: true
+ update_series:
+ description: 'Update php-sdk series files'
+ type: boolean
+ required: true
jobs:
   print-inputs:
     runs-on: ubuntu-latest
@@ -55,4 +59,4 @@ jobs:
           --request POST \
           --location https://downloads.php.net/api/winlibs \
           --header 'Authorization: Bearer ${{ secrets.AUTH_TOKEN }}' \
- --data '{ "library": "${{ inputs.library }}", "ref": "${{ inputs.ref }}", "type": "${{ inputs.type }}", "workflow_run_id": "${{ inputs.workflow_run_id }}", "php_versions": "${{ inputs.php_versions }}", "vs_version": "${{ inputs.vs_version }}", "vs_version_targets": "${{ inputs.vs_version_targets }}", "stability": "${{ inputs.stability }}", "token": "${{ secrets.TOKEN }}" }'
+ --data '{ "library": "${{ inputs.library }}", "ref": "${{ inputs.ref }}", "type": "${{ inputs.type }}", "workflow_run_id": "${{ inputs.workflow_run_id }}", "php_versions": "${{ inputs.php_versions }}", "vs_version_targets": "${{ inputs.vs_version_targets }}", "stability": "${{ inputs.stability }}", "token": "${{ secrets.TOKEN }}", "update_series": "${{ inputs.update_series }}" }'
diff --git a/API.md b/API.md
index 046a3c0..947d095 100644
--- a/API.md
+++ b/API.md
@@ -155,6 +155,7 @@ curl -i -X POST \
     - `php_versions` (string, required): Comma-separated list matching `^(?:\d+\.\d+|master)(?:,\s*(?:\d+\.\d+|master))*$`.
     - `vs_version_targets` (string, required): Comma-separated list matching `^(v[c|s]\d{2})(,v[c|s]\d{2})*$`.
     - `stability` (string, required): `stable`, `staging`, or both (comma-separated) matching `^(stable|staging)(,(stable|staging))?$`.
+ - `update_series` (string, required): `true` or `false`.
     - `token` (string, required): GitHub token used to download artifacts.
- Success: `200 OK`, empty body.
- Errors:
@@ -170,10 +171,12 @@ curl -i -X POST \
     -d '{
             "library": "icu",
             "ref": "main",
+ "type": "php",
             "workflow_run_id": "1234567890",
             "php_versions": "8.1,8.2,8.3",
             "vs_version_targets": "vc15,vs16",
             "stability": "stable",
+ "update_series": "true",
             "token": "ghp_..."
         }' \
     https://downloads.php.net/api/winlibs
diff --git a/src/Console/Command/WinlibsCommand.php b/src/Console/Command/WinlibsCommand.php
index d0c770c..81ac219 100644
--- a/src/Console/Command/WinlibsCommand.php
+++ b/src/Console/Command/WinlibsCommand.php
@@ -50,13 +50,16 @@ public function handle(): int
                 if ($files) {
                     if($data['type'] === 'php') {
                         $this->copyPhpFiles($files, $data['library'], $data['vs_version_targets']);
- $this->updatePhpSeriesFiles(
- $files,
- $data['library'],
- $data['php_versions'],
- $data['vs_version_targets'],
- $data['stability']
- );
+ $updateSeries = $data['update_series'] ?? 'true';
+ if ($updateSeries === 'true') {
+ $this->updatePhpSeriesFiles(
+ $files,
+ $data['library'],
+ $data['php_versions'],
+ $data['vs_version_targets'],
+ $data['stability']
+ );
+ }
                     } else {
                         $this->copyPeclFiles($files, $data['library']);
                         $this->updatePackagesFile($files, $data['library']);
diff --git a/src/Http/Controllers/WinlibsController.php b/src/Http/Controllers/WinlibsController.php
index e582be1..441a091 100644
--- a/src/Http/Controllers/WinlibsController.php
+++ b/src/Http/Controllers/WinlibsController.php
@@ -19,6 +19,7 @@ protected function validate(array $data): bool
             'php_versions' => 'required|string|regex:/^(?:\d+\.\d+|master)(?:,\s*(?:\d+\.\d+|master))*$/',
             'vs_version_targets' => 'required|string|regex:/^(v[c|s]\d{2})(,v[c|s]\d{2})*$/',
             'stability' => 'required|string|regex:/^(stable|staging)(,(stable|staging))?$/',
+ 'update_series' => 'required|string|regex:/^(true|false)$/',
             'token' => 'required|string',
         ]);

@@ -40,4 +41,4 @@ protected function execute(array $data): void
         $directory = getenv('BUILDS_DIRECTORY') . '/winlibs/' . $data['workflow_run_id'];
         file_put_contents($directory . '/data.json', json_encode($data));
     }
-}
\ No newline at end of file
+}
diff --git a/tests/Console/Command/WinlibsCommandTest.php b/tests/Console/Command/WinlibsCommandTest.php
index 9334dbe..4a10d9b 100644
--- a/tests/Console/Command/WinlibsCommandTest.php
+++ b/tests/Console/Command/WinlibsCommandTest.php
@@ -49,7 +49,8 @@ public function testSuccessfulFileOperations($phpVersion, $vsVersion, $arch, $st
             'ref' => $ref,
             'vs_version_targets' => $vsVersion,
             'php_versions' => $phpVersion,
- 'stability' => $stability
+ 'stability' => $stability,
+ 'update_series' => 'true',
         ]));

         $zipPath = $this->winlibsDirectory . "/lib/lib-$ref-$vsVersion-$arch.zip";
@@ -85,7 +86,8 @@ public function testSuccessfulFileOperationsWithExistingSeriesFile($phpVersion,
             'ref' => $ref,
             'vs_version_targets' => $vsVersion,
             'php_versions' => $phpVersion,
- 'stability' => $stability
+ 'stability' => $stability,
+ 'update_series' => 'true',
         ]));

         file_put_contents($seriesFilePath, "existing-$ref-$vsVersion-$arch.zip");
@@ -123,7 +125,8 @@ public function testSuccessfulFileOperationsWithExistingOldLibraryInSeriesFile($
             'ref' => $ref,
             'vs_version_targets' => $vsVersion,
             'php_versions' => $phpVersion,
- 'stability' => $stability
+ 'stability' => $stability,
+ 'update_series' => 'true',
         ]));

         file_put_contents($seriesFilePath, "lib-1.0.0-$vsVersion-$arch.zip");
@@ -162,7 +165,8 @@ public function testSuccessfulPeclFileOperations(): void
             'ref' => $ref,
             'vs_version_targets' => $vsVersion,
             'php_versions' => '8.2',
- 'stability' => 'stable'
+ 'stability' => 'stable',
+ 'update_series' => 'true',
         ]));

         $zipPath = $this->winlibsDirectory . "/redis/redis-$ref-$vsVersion-$arch.zip";
@@ -254,7 +258,8 @@ public function testSyncsStableAndStagingSeriesFilesForConfiguredUpcomingSeries(
             'ref' => $ref,
             'vs_version_targets' => $vsVersion,
             'php_versions' => $phpVersion,
- 'stability' => 'staging'
+ 'stability' => 'staging',
+ 'update_series' => 'true',
         ]));

         $zipPath = $this->winlibsDirectory . "/lib/lib-$ref-$vsVersion-$arch.zip";
@@ -281,6 +286,51 @@ public function testSyncsStableAndStagingSeriesFilesForConfiguredUpcomingSeries(
         );
     }

+ public function testCopiesPhpSdkFilesWithoutUpdatingSeriesWhenDisabled(): void
+ {
+ mkdir($this->winlibsDirectory . '/curl', 0755, true);
+ mkdir($this->baseDirectory . '/php-sdk/deps/series', 0755, true);
+
+ $library = 'curl';
+ $ref = '8.8.0';
+ $phpVersion = '8.4';
+ $vsVersion = 'vs17';
+ $arch = 'x64';
+ $seriesFilePath = $this->baseDirectory . "/php-sdk/deps/series/packages-$phpVersion-$vsVersion-$arch-staging.txt";
+
+ file_put_contents($seriesFilePath, "existing-entry-$vsVersion-$arch.zip");
+
+ file_put_contents($this->winlibsDirectory . '/curl/data.json', json_encode([
+ 'type' => 'php',
+ 'library' => $library,
+ 'ref' => $ref,
+ 'vs_version_targets' => $vsVersion,
+ 'php_versions' => $phpVersion,
+ 'stability' => 'staging',
+ 'update_series' => 'false',
+ ]));
+
+ $zipPath = $this->winlibsDirectory . "/curl/curl-$ref-$vsVersion-$arch.zip";
+ $zip = new ZipArchive();
+ if ($zip->open($zipPath, ZipArchive::CREATE) === TRUE) {
+ $zip->addFromString('dummy_file.txt', 'dummy content');
+ $zip->close();
+ }
+
+ $command = new WinlibsCommand();
+ $command->setOption('base-directory', $this->baseDirectory);
+ $command->setOption('builds-directory', $this->buildsDirectory);
+
+ $result = $command->handle();
+
+ $this->assertSame(0, $result);
+ $this->assertFileExists($this->baseDirectory . "/php-sdk/deps/$vsVersion/$arch/curl-$ref-$vsVersion-$arch.zip");
+ $this->assertSame(
+ 'existing-entry-vs17-x64.zip',
+ file_get_contents($seriesFilePath)
+ );
+ }
+
     public function testCommandHandlesMissingBaseDirectory(): void
     {
         $command = new WinlibsCommand();
@@ -315,7 +365,8 @@ public function testHandlesNoValidFilesInJob(): void
             'ref' => '1.0.0',
             'vs_version_targets' => 'vs16',
             'php_versions' => '8.2',
- 'stability' => 'stable'
+ 'stability' => 'stable',
+ 'update_series' => 'true',
         ]));
         file_put_contents($this->winlibsDirectory . '/lib/not-a-valid-file.zip', 'dummy');

@@ -410,7 +461,8 @@ private function runPeclWinlibsCommand(string $buildName, string $library, strin
             'ref' => $ref,
             'vs_version_targets' => $vsVersion,
             'php_versions' => '8.2',
- 'stability' => 'stable'
+ 'stability' => 'stable',
+ 'update_series' => 'true',
         ]));

         $zipPath = $directory . "/$buildName-$ref-$vsVersion-$arch.zip";