Add ReleaseIdentifier to logging
This commit is contained in:
parent
1a447627c7
commit
31e97defd1
@ -14,8 +14,22 @@ using Serilog;
|
|||||||
|
|
||||||
namespace AppScaffolding
|
namespace AppScaffolding
|
||||||
{
|
{
|
||||||
|
|
||||||
|
public enum ReleaseIdentifier
|
||||||
|
{
|
||||||
|
WindowsClassic,
|
||||||
|
WindowsAvalonia,
|
||||||
|
LinuxAvalonia,
|
||||||
|
MacOSAvalonia
|
||||||
|
}
|
||||||
|
|
||||||
public static class LibationScaffolding
|
public static class LibationScaffolding
|
||||||
{
|
{
|
||||||
|
public static ReleaseIdentifier ReleaseIdentifier { get; private set; }
|
||||||
|
|
||||||
|
public static void SetReleaseIdentifier(ReleaseIdentifier releaseID)
|
||||||
|
=> ReleaseIdentifier = releaseID;
|
||||||
|
|
||||||
// AppScaffolding
|
// AppScaffolding
|
||||||
private static Assembly _executingAssembly;
|
private static Assembly _executingAssembly;
|
||||||
private static Assembly ExecutingAssembly
|
private static Assembly ExecutingAssembly
|
||||||
@ -280,6 +294,7 @@ namespace AppScaffolding
|
|||||||
Log.Logger.Information("Begin. {@DebugInfo}", new
|
Log.Logger.Information("Begin. {@DebugInfo}", new
|
||||||
{
|
{
|
||||||
AppName = EntryAssembly.GetName().Name,
|
AppName = EntryAssembly.GetName().Name,
|
||||||
|
ReleaseIdentifier = ReleaseIdentifier,
|
||||||
Version = BuildVersion.ToString(),
|
Version = BuildVersion.ToString(),
|
||||||
Mode = mode,
|
Mode = mode,
|
||||||
LogLevel_Verbose_Enabled = Log.Logger.IsVerboseEnabled(),
|
LogLevel_Verbose_Enabled = Log.Logger.IsVerboseEnabled(),
|
||||||
@ -309,18 +324,10 @@ namespace AppScaffolding
|
|||||||
LibraryCommands.BookUserDefinedItemCommitted += (_, books) => SearchEngineCommands.UpdateBooks(books);
|
LibraryCommands.BookUserDefinedItemCommitted += (_, books) => SearchEngineCommands.UpdateBooks(books);
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum ReleaseIdentifier
|
public static UpgradeProperties GetLatestRelease()
|
||||||
{
|
|
||||||
WindowsClassic,
|
|
||||||
WindowsAvalonia,
|
|
||||||
LinuxAvalonia,
|
|
||||||
MacOSAvalonia
|
|
||||||
}
|
|
||||||
|
|
||||||
public static UpgradeProperties GetLatestRelease(ReleaseIdentifier releaseID = ReleaseIdentifier.WindowsClassic)
|
|
||||||
{
|
{
|
||||||
// timed out
|
// 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)
|
if (latest is null || zip is null)
|
||||||
return null;
|
return null;
|
||||||
@ -346,11 +353,11 @@ namespace AppScaffolding
|
|||||||
|
|
||||||
return new(zipUrl, latest.HtmlUrl, zip.Name, latestRelease);
|
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
|
try
|
||||||
{
|
{
|
||||||
var task = getLatestRelease(releaseID);
|
var task = getLatestRelease();
|
||||||
if (task.Wait(timeout))
|
if (task.Wait(timeout))
|
||||||
return task.Result;
|
return task.Result;
|
||||||
|
|
||||||
@ -362,7 +369,7 @@ namespace AppScaffolding
|
|||||||
}
|
}
|
||||||
return (null, null);
|
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 ownerAccount = "rmcrackan";
|
||||||
var repoName = "Libation";
|
var repoName = "Libation";
|
||||||
@ -372,7 +379,7 @@ namespace AppScaffolding
|
|||||||
//Download the release index
|
//Download the release index
|
||||||
var bts = await gitHubClient.Repository.Content.GetRawContent(ownerAccount, repoName, ".releaseindex.json");
|
var bts = await gitHubClient.Repository.Content.GetRawContent(ownerAccount, repoName, ".releaseindex.json");
|
||||||
var releaseIndex = JObject.Parse(System.Text.Encoding.ASCII.GetString(bts));
|
var releaseIndex = JObject.Parse(System.Text.Encoding.ASCII.GetString(bts));
|
||||||
var regexPattern = releaseIndex.Value<string>(releaseID.ToString());
|
var regexPattern = releaseIndex.Value<string>(ReleaseIdentifier.ToString());
|
||||||
|
|
||||||
// https://octokitnet.readthedocs.io/en/latest/releases/
|
// https://octokitnet.readthedocs.io/en/latest/releases/
|
||||||
var releases = await gitHubClient.Repository.Release.GetAll(ownerAccount, repoName);
|
var releases = await gitHubClient.Repository.Release.GetAll(ownerAccount, repoName);
|
||||||
|
|||||||
@ -18,6 +18,8 @@ namespace LibationAvalonia
|
|||||||
public class App : Application
|
public class App : Application
|
||||||
{
|
{
|
||||||
public static bool IsWindows => PlatformID is PlatformID.Win32NT;
|
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 bool IsUnix => PlatformID is PlatformID.Unix;
|
||||||
|
|
||||||
public static readonly PlatformID PlatformID = Environment.OSVersion.Platform;
|
public static readonly PlatformID PlatformID = Environment.OSVersion.Platform;
|
||||||
|
|||||||
@ -30,6 +30,11 @@ namespace LibationAvalonia
|
|||||||
var classicLifetimeTask = Task.Run(() => new ClassicDesktopStyleApplicationLifetime());
|
var classicLifetimeTask = Task.Run(() => new ClassicDesktopStyleApplicationLifetime());
|
||||||
var appBuilderTask = Task.Run(BuildAvaloniaApp);
|
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)
|
if (!App.SetupRequired)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -30,6 +30,8 @@ namespace LibationWinForms
|
|||||||
|
|
||||||
ApplicationConfiguration.Initialize();
|
ApplicationConfiguration.Initialize();
|
||||||
|
|
||||||
|
AppScaffolding.LibationScaffolding.SetReleaseIdentifier(AppScaffolding.ReleaseIdentifier.WindowsClassic);
|
||||||
|
|
||||||
//***********************************************//
|
//***********************************************//
|
||||||
// //
|
// //
|
||||||
// do not use Configuration before this line //
|
// do not use Configuration before this line //
|
||||||
@ -170,7 +172,7 @@ namespace LibationWinForms
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
upgradeProperties = AppScaffolding.LibationScaffolding.GetLatestRelease(AppScaffolding.LibationScaffolding.ReleaseIdentifier.WindowsClassic);
|
upgradeProperties = AppScaffolding.LibationScaffolding.GetLatestRelease();
|
||||||
if (upgradeProperties is null)
|
if (upgradeProperties is null)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user