Skip to content

Commit

Permalink
Handle GitHub releases with multiple signatures
Browse files Browse the repository at this point in the history
  • Loading branch information
lkrms committed Feb 2, 2024
1 parent 951f615 commit 1cfd8a8
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/shared/repository/GithubRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
Expand All @@ -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);
}
}

Expand All @@ -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(
Expand Down

0 comments on commit 1cfd8a8

Please sign in to comment.