Add release packaging and automatic update support
This commit is contained in:
parent
94cd6b984b
commit
f971c374f8
20 changed files with 722 additions and 16 deletions
29
src/AstroFrame.Desktop/UpdateDiagnostics.cs
Normal file
29
src/AstroFrame.Desktop/UpdateDiagnostics.cs
Normal 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; }
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue