diff --git a/src/shared/repository/GithubRepository.php b/src/shared/repository/GithubRepository.php index 54671160..f2620dcc 100644 --- a/src/shared/repository/GithubRepository.php +++ b/src/shared/repository/GithubRepository.php @@ -36,7 +36,7 @@ public function getReleasesByRequestedPhar(RequestedPhar $requestedPhar): Releas continue; } $pharUrl = null; - $signatureUrl = null; + $signatureUrl = []; foreach ($entry['assets'] as $asset) { $url = $asset['browser_download_url']; @@ -48,7 +48,7 @@ public function getReleasesByRequestedPhar(RequestedPhar $requestedPhar): Releas } if (in_array(substr($url, -4, 4), ['.asc', '.sig'], true)) { - $signatureUrl = new Url($url); + $signatureUrl[$url] = new Url($url); } } @@ -61,6 +61,12 @@ public function getReleasesByRequestedPhar(RequestedPhar $requestedPhar): Releas continue; } + // if the release has multiple signatures, use the one that's closest to the + // name of the phar, e.g. doctum.phar.asc instead of doctum.phar.sha256.asc + $signatureUrl = $signatureUrl[$pharUrl . '.asc'] + ?? $signatureUrl[$pharUrl . '.sig'] + ?? array_shift($signatureUrl); + // we do have a phar but no signature, could potentially be used if (!$signatureUrl instanceof Url) { $releases->add(