backoffice: manage launcher auto-update from the Versions page

Two things change so the operator never has to SSH for a launcher
release.

1. SignManifest::run() now also re-hashes the manifest's `launcher`
   section. It looks for builds/launcher/<basename of launcher.url>;
   falls back to a tolerant glob *<version>*.exe if the exact name
   isn't found. Updates sizeBytes + sha256 in place. The Ed25519 sign
   step at the end already covered this branch — it was just blank
   data before.

2. admin/versions.php has a new "Auto-update du launcher" card above
   the manifest table. Shows the announced version + minRequired, the
   exe presence badge and the hash status, and a small form to set or
   update the launcher entry (version + minRequired only — URL is
   derived from base_url + version automatically). A "Retirer la
   section" button disables the auto-update by deleting the launcher
   key from versions.json. Lists the .exe files present in
   builds/launcher/ for visibility.

Workflow now: edit the version in the form → SFTP-upload
PSLauncher-X.Y.Z.exe to builds/launcher/ → click "🔁 Sync" once →
manifest is hashed and signed.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-02 10:39:56 +02:00
parent 6bc5381562
commit 197b07966c
2 changed files with 130 additions and 0 deletions

View File

@@ -82,6 +82,33 @@ final class SignManifest
}
unset($v);
// Section launcher : si présente, on tente de hasher le PSLauncher-{ver}.exe
// dans builds/launcher/. On ignore proprement si l'exe n'est pas là.
if (isset($manifest['launcher']) && is_array($manifest['launcher'])) {
$launcher = &$manifest['launcher'];
$lver = $launcher['version'] ?? '';
$lurl = $launcher['download']['url'] ?? '';
if ($lver !== '' && $lurl !== '') {
$lfile = basename(parse_url($lurl, PHP_URL_PATH) ?: '');
$lpath = "{$this->buildsDir}/launcher/{$lfile}";
if (!is_file($lpath)) {
// Fallback : tolérant sur le nom (PSLauncher-X.Y.Z.exe, etc.)
$candidates = glob("{$this->buildsDir}/launcher/*{$lver}*.exe", GLOB_NOSORT) ?: [];
if (count($candidates) === 1) $lpath = $candidates[0];
}
if (is_file($lpath)) {
$lsize = filesize($lpath);
$lsha = hash_file('sha256', $lpath);
$launcher['download']['sizeBytes'] = $lsize;
$launcher['download']['sha256'] = $lsha;
$this->out(" [launcher] v{$lver} : " . basename($lpath) . " ({$lsize} octets) sha256={$lsha}");
} else {
$this->out(" [launcher] v{$lver} : exe introuvable dans builds/launcher/");
}
}
unset($launcher);
}
// Bump auto de `latest` sur la plus haute version effectivement uploadée
if (!empty($hashedVersions)) {
usort($hashedVersions, 'version_compare');