From 820056e8f4f2598cd122abd7ddc48c1fba723dd5 Mon Sep 17 00:00:00 2001 From: Shivam Mathur Date: Fri, 14 Feb 2025 06:50:27 +0530 Subject: [PATCH] Fix winlibs uploads --- .github/workflows/winlibs.yml | 3 --- src/Actions/GetArtifacts.php | 2 +- src/Http/Controllers/WinlibsController.php | 5 ++--- src/Validator.php | 14 +++++++++++--- 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/.github/workflows/winlibs.yml b/.github/workflows/winlibs.yml index 53fff63..9bbb196 100644 --- a/.github/workflows/winlibs.yml +++ b/.github/workflows/winlibs.yml @@ -15,9 +15,6 @@ on: php_versions: description: 'PHP Versions' required: true - vs_version: - description: 'VS Versions' - required: true vs_version_targets: description: 'VS Version Targets' required: true diff --git a/src/Actions/GetArtifacts.php b/src/Actions/GetArtifacts.php index 0dc4c5a..3eb92cb 100644 --- a/src/Actions/GetArtifacts.php +++ b/src/Actions/GetArtifacts.php @@ -10,7 +10,7 @@ public function handle($workflow_run_id, $token): void { $ch = curl_init(); - $base_url = "https://api.github.com/repos/"; + $base_url = "https://api.github.com/repos"; $repo = "winlibs/winlib-builder"; diff --git a/src/Http/Controllers/WinlibsController.php b/src/Http/Controllers/WinlibsController.php index 88f4d0d..aca9fb8 100644 --- a/src/Http/Controllers/WinlibsController.php +++ b/src/Http/Controllers/WinlibsController.php @@ -14,9 +14,8 @@ protected function validate(array $data): bool 'library' => 'required|string', 'ref' => 'required|string', 'workflow_run_id' => 'required|string', - 'php_versions' => 'required|string|regex:/^\d+\.\d+$}|^master$/', - 'vs_version' => 'required|string|regex:/^(v[c|s]\d{2})(,v[c|s]\d{2})*$/', - 'vs_version_targets' => 'required|string|regex:/^v[c|s]\d{2}$/', + '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))?$/', 'token' => 'required|string', ]); diff --git a/src/Validator.php b/src/Validator.php index 1330f95..119b23a 100644 --- a/src/Validator.php +++ b/src/Validator.php @@ -20,9 +20,17 @@ public function validate(array $data): void $this->errors = []; foreach ($this->rules as $field => $ruleString) { - $rulesArray = explode('|', $ruleString); - foreach ($rulesArray as $rule) { - $ruleParts = explode(':', $rule); + $regexPos = strpos($ruleString, 'regex:'); + if ($regexPos !== false) { + $nonRegexPart = substr($ruleString, 0, $regexPos); + $nonRegexRules = array_filter(explode('|', rtrim($nonRegexPart, '|'))); + $regexRule = substr($ruleString, $regexPos); + $rules = array_merge($nonRegexRules, [$regexRule]); + } else { + $rules = array_filter(explode('|', $ruleString)); + } + foreach ($rules as $rule) { + $ruleParts = explode(':', $rule, 2); $ruleName = $ruleParts[0]; $ruleValue = $ruleParts[1] ?? null;