diff --git a/Source/AppScaffolding/LibationScaffolding.cs b/Source/AppScaffolding/LibationScaffolding.cs index 33f385c7..825df95e 100644 --- a/Source/AppScaffolding/LibationScaffolding.cs +++ b/Source/AppScaffolding/LibationScaffolding.cs @@ -14,8 +14,22 @@ using Serilog; namespace AppScaffolding { + + public enum ReleaseIdentifier + { + WindowsClassic, + WindowsAvalonia, + LinuxAvalonia, + MacOSAvalonia + } + public static class LibationScaffolding { + public static ReleaseIdentifier ReleaseIdentifier { get; private set; } + + public static void SetReleaseIdentifier(ReleaseIdentifier releaseID) + => ReleaseIdentifier = releaseID; + // AppScaffolding private static Assembly _executingAssembly; private static Assembly ExecutingAssembly @@ -280,6 +294,7 @@ namespace AppScaffolding Log.Logger.Information("Begin. {@DebugInfo}", new { AppName = EntryAssembly.GetName().Name, + ReleaseIdentifier = ReleaseIdentifier, Version = BuildVersion.ToString(), Mode = mode, LogLevel_Verbose_Enabled = Log.Logger.IsVerboseEnabled(), @@ -309,18 +324,10 @@ namespace AppScaffolding LibraryCommands.BookUserDefinedItemCommitted += (_, books) => SearchEngineCommands.UpdateBooks(books); } - public enum ReleaseIdentifier - { - WindowsClassic, - WindowsAvalonia, - LinuxAvalonia, - MacOSAvalonia - } - - public static UpgradeProperties GetLatestRelease(ReleaseIdentifier releaseID = ReleaseIdentifier.WindowsClassic) + public static UpgradeProperties GetLatestRelease() { // timed out - (var latest, var zip) = getLatestRelease(TimeSpan.FromSeconds(10), releaseID); + (var latest, var zip) = getLatestRelease(TimeSpan.FromSeconds(10)); if (latest is null || zip is null) return null; @@ -346,11 +353,11 @@ namespace AppScaffolding return new(zipUrl, latest.HtmlUrl, zip.Name, latestRelease); } - private static (Octokit.Release, Octokit.ReleaseAsset) getLatestRelease(TimeSpan timeout, ReleaseIdentifier releaseID) + private static (Octokit.Release, Octokit.ReleaseAsset) getLatestRelease(TimeSpan timeout) { try { - var task = getLatestRelease(releaseID); + var task = getLatestRelease(); if (task.Wait(timeout)) return task.Result; @@ -362,7 +369,7 @@ namespace AppScaffolding } return (null, null); } - private static async System.Threading.Tasks.Task<(Octokit.Release, Octokit.ReleaseAsset)> getLatestRelease(ReleaseIdentifier releaseID) + private static async System.Threading.Tasks.Task<(Octokit.Release, Octokit.ReleaseAsset)> getLatestRelease() { var ownerAccount = "rmcrackan"; var repoName = "Libation"; @@ -372,7 +379,7 @@ namespace AppScaffolding //Download the release index var bts = await gitHubClient.Repository.Content.GetRawContent(ownerAccount, repoName, ".releaseindex.json"); var releaseIndex = JObject.Parse(System.Text.Encoding.ASCII.GetString(bts)); - var regexPattern = releaseIndex.Value(releaseID.ToString()); + var regexPattern = releaseIndex.Value(ReleaseIdentifier.ToString()); // https://octokitnet.readthedocs.io/en/latest/releases/ var releases = await gitHubClient.Repository.Release.GetAll(ownerAccount, repoName); diff --git a/Source/LibationAvalonia/App.axaml.cs b/Source/LibationAvalonia/App.axaml.cs index 8d806fc8..90a1ea43 100644 --- a/Source/LibationAvalonia/App.axaml.cs +++ b/Source/LibationAvalonia/App.axaml.cs @@ -18,6 +18,8 @@ namespace LibationAvalonia public class App : Application { public static bool IsWindows => PlatformID is PlatformID.Win32NT; + + //This is trye for both linux and mac. We'll need a way to dintinguis between those two after we get mac to actually run. public static bool IsUnix => PlatformID is PlatformID.Unix; public static readonly PlatformID PlatformID = Environment.OSVersion.Platform; diff --git a/Source/LibationAvalonia/Program.cs b/Source/LibationAvalonia/Program.cs index 8410798f..d762f379 100644 --- a/Source/LibationAvalonia/Program.cs +++ b/Source/LibationAvalonia/Program.cs @@ -30,6 +30,11 @@ namespace LibationAvalonia var classicLifetimeTask = Task.Run(() => new ClassicDesktopStyleApplicationLifetime()); var appBuilderTask = Task.Run(BuildAvaloniaApp); + if (App.IsWindows) + AppScaffolding.LibationScaffolding.SetReleaseIdentifier(AppScaffolding.ReleaseIdentifier.WindowsAvalonia); + else if (App.IsUnix) + AppScaffolding.LibationScaffolding.SetReleaseIdentifier(AppScaffolding.ReleaseIdentifier.LinuxAvalonia); + if (!App.SetupRequired) { diff --git a/Source/LibationWinForms/Program.cs b/Source/LibationWinForms/Program.cs index 36b174a2..53833005 100644 --- a/Source/LibationWinForms/Program.cs +++ b/Source/LibationWinForms/Program.cs @@ -30,6 +30,8 @@ namespace LibationWinForms ApplicationConfiguration.Initialize(); + AppScaffolding.LibationScaffolding.SetReleaseIdentifier(AppScaffolding.ReleaseIdentifier.WindowsClassic); + //***********************************************// // // // do not use Configuration before this line // @@ -170,7 +172,7 @@ namespace LibationWinForms try { - upgradeProperties = AppScaffolding.LibationScaffolding.GetLatestRelease(AppScaffolding.LibationScaffolding.ReleaseIdentifier.WindowsClassic); + upgradeProperties = AppScaffolding.LibationScaffolding.GetLatestRelease(); if (upgradeProperties is null) return; }