fix: finalize draft releases by asset id

This commit is contained in:
leokun
2026-08-26 22:44:27 +08:00
parent f6be6c2b27
commit 2c95d7f836
2 changed files with 22 additions and 8 deletions
+10 -6
View File
@@ -36,22 +36,26 @@ export function normalizeTauriUpdate(manifest, release, repository, version) {
throw new Error("updater manifest has no platforms");
}
const assetsByApiUrl = new Map();
const assetsBySourceUrl = new Map();
const publicAssetUrls = new Set();
for (const asset of release.assets ?? []) {
if (!asset?.id || !asset?.browser_download_url) continue;
assetsByApiUrl.set(
if (!asset?.id || !asset?.name) continue;
const publicUrl = `https://github.com/${repository}/releases/download/v${version}/${encodeURIComponent(asset.name)}`;
assetsBySourceUrl.set(
`https://api.github.com/repos/${repository}/releases/assets/${asset.id}`,
asset.browser_download_url,
publicUrl,
);
publicAssetUrls.add(asset.browser_download_url);
if (asset.browser_download_url) {
assetsBySourceUrl.set(asset.browser_download_url, publicUrl);
}
publicAssetUrls.add(publicUrl);
}
for (const [platform, entry] of Object.entries(manifest.platforms)) {
if (!entry?.signature || !entry?.url) {
throw new Error(`updater platform ${platform} is missing its URL or signature`);
}
const publicUrl = assetsByApiUrl.get(entry.url) ?? entry.url;
const publicUrl = assetsBySourceUrl.get(entry.url) ?? entry.url;
if (!publicAssetUrls.has(publicUrl)) {
throw new Error(`updater platform ${platform} references an unknown release asset`);
}