Dev publish: new archive before deleting the old, manifest last (a failed upload no longer empties the dev release)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
foxyzandClaude Opus 5.5 committed 2026-10-11 16:21:05 +03:00
1 parent ddd7a21195
commit 86eb30f498
1 file changed
+16 -10
+16 -10
View File
@@ -110,8 +110,8 @@ String _apiBase(String root) {
return '$server/api/v1/repos/$repo'; return '$server/api/v1/repos/$repo';
} }
// The `dev` prerelease (created at main's head on first use): every old // The `dev` prerelease (created at main's head on first use): [files]
// asset deleted, then [files] uploaded. Its manifest's URL is fixed, so // uploaded (the manifest last), the previous ones deleted. Its manifest's URL is fixed, so
// test builds find each new one. // test builds find each new one.
Future<void> _publishDev(String root, List<File> files) async { Future<void> _publishDev(String root, List<File> files) async {
final token = _token(); final token = _token();
@@ -130,17 +130,23 @@ Future<void> _publishDev(String root, List<File> files) async {
}) ?? }) ??
_die('could not create or find release dev'); _die('could not create or find release dev');
final id = rel['id']; final id = rel['id'];
for (final a in (rel['assets'] as List? ?? const [])) { final old = [for (final a in (rel['assets'] as List? ?? const [])) if (a is Map) a];
if (a is Map) await c.delete('$api/releases/$id/assets/${a['id']}'); Future<void> upload(File f) {
}
for (final f in files) {
final name = f.uri.pathSegments.last; final name = f.uri.pathSegments.last;
stdout.writeln('uploading $name ...'); stdout.writeln('uploading $name ...');
await c.upload( return c.upload('$api/releases/$id/assets?name=${Uri.encodeQueryComponent(name)}', f, name);
'$api/releases/$id/assets?name=${Uri.encodeQueryComponent(name)}',
f,
name);
} }
// The archive first, the old assets after, the manifest last: a failed
// upload leaves the previous build in place, never an empty release.
final manifest = files.last;
for (final f in files.take(files.length - 1)) {
await upload(f);
}
for (final a in old) {
await c.delete('$api/releases/$id/assets/${a['id']}');
}
await upload(manifest);
stdout.writeln('published to dev.'); stdout.writeln('published to dev.');
} finally { } finally {
http.close(); http.close();