Add release packaging and automatic update support

This commit is contained in:
Elijah 2026-10-03 19:07:11 -07:00
parent 94cd6b984b
commit f971c374f8
20 changed files with 722 additions and 16 deletions

View file

@ -0,0 +1,29 @@
using System.Text.Json;
using Velopack;
namespace AstroFrame.Desktop;
// Explicit local-feed probe used to verify installed package lifecycle without publishing test releases.
internal static class UpdateDiagnostics
{
public static async Task<int> Run(string[] args)
{
string report = Path.GetFullPath(args[2]);
try
{
string feed = args[1] == ReleaseUpdateBackend.Repository ? args[1] : Path.GetFullPath(args[1]);
var options = new UpdateOptions { ExplicitChannel = OperatingSystem.IsWindows() ? "win-x64" : "linux-x64" };
var manager = feed == ReleaseUpdateBackend.Repository
? new UpdateManager(new Velopack.Sources.GiteaSource(feed, null, false), options)
: new UpdateManager(feed, options);
if (!manager.IsInstalled) throw new InvalidOperationException("Probe requires an installed Windows package or Linux AppImage.");
var update = await manager.CheckForUpdatesAsync();
if (update != null) await manager.DownloadUpdatesAsync(update);
var record = new { version = manager.CurrentVersion?.ToString(), available = update?.TargetFullRelease.Version.ToString(), downloaded = manager.UpdatePendingRestart?.Version.ToString() };
File.AppendAllText(report, JsonSerializer.Serialize(record) + Environment.NewLine);
if (update != null && args.Contains("--apply")) manager.WaitExitThenApplyUpdates(update.TargetFullRelease, silent: true, restart: true, restartArgs: ["--verify-update", feed, report]);
return 0;
}
catch (Exception e) { File.AppendAllText(report, e + Environment.NewLine); return 1; }
}
}