From 0c2ba2651bed499a6421087345dbd84823fcbc24 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Mon, 6 Dec 2021 22:21:02 -0600 Subject: use semantic version --- src/slskd/Application.cs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src/slskd/Application.cs') diff --git a/src/slskd/Application.cs b/src/slskd/Application.cs index d0cbe361..856b898d 100644 --- a/src/slskd/Application.cs +++ b/src/slskd/Application.cs @@ -141,10 +141,11 @@ namespace slskd /// The operation context. public async Task CheckVersionAsync() { - if (Program.InformationalVersion.EndsWith("65534")) + if (Program.IsCanary) { // todo: use the docker hub API to find the latest canary tag Logger.Information("Skipping version check for Canary build; check for updates manually."); + return; } Logger.Information("Checking GitHub Releases for latest version"); @@ -154,17 +155,17 @@ namespace slskd var latestVersion = await GitHub.GetLatestReleaseVersion( organization: Program.AppName, repository: Program.AppName, - userAgent: $"{Program.AppName} v{Program.InformationalVersion}"); + userAgent: $"{Program.AppName} v{Program.FullVersion}"); - if (latestVersion > Version.Parse(Program.InformationalVersion)) + if (latestVersion > Version.Parse(Program.SemanticVersion)) { State.SetValue(state => state with { Version = state.Version with { Latest = latestVersion.ToString(), IsUpdateAvailable = true } }); - Logger.Information("A new version is available! {CurrentVersion} -> {LatestVersion}", Program.InformationalVersion, latestVersion); + Logger.Information("A new version is available! {CurrentVersion} -> {LatestVersion}", Program.SemanticVersion, latestVersion); } else { - State.SetValue(state => state with { Version = state.Version with { Latest = Program.InformationalVersion, IsUpdateAvailable = false } }); - Logger.Information("Version {CurrentVersion} is up to date.", Program.InformationalVersion); + State.SetValue(state => state with { Version = state.Version with { Latest = Program.SemanticVersion, IsUpdateAvailable = false } }); + Logger.Information("Version {CurrentVersion} is up to date.", Program.SemanticVersion); } } catch (Exception ex) -- cgit v1.2.3 From f6818c2e2f8511cdd59e6254ce1936d2d82727df Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Tue, 7 Dec 2021 09:18:07 -0600 Subject: add flag and behavior for development builds --- src/slskd/Application.cs | 6 ++++++ src/slskd/Program.cs | 15 +++++++++++++++ src/slskd/State.cs | 1 + 3 files changed, 22 insertions(+) (limited to 'src/slskd/Application.cs') diff --git a/src/slskd/Application.cs b/src/slskd/Application.cs index 856b898d..021a6c40 100644 --- a/src/slskd/Application.cs +++ b/src/slskd/Application.cs @@ -141,6 +141,12 @@ namespace slskd /// The operation context. public async Task CheckVersionAsync() { + if (Program.IsDevelopment) + { + Logger.Information("Skipping version check for Development build"); + return; + } + if (Program.IsCanary) { // todo: use the docker hub API to find the latest canary tag diff --git a/src/slskd/Program.cs b/src/slskd/Program.cs index 5d81c5a5..b109c76b 100644 --- a/src/slskd/Program.cs +++ b/src/slskd/Program.cs @@ -113,6 +113,11 @@ namespace slskd /// public static bool IsCanary => AssemblyVersion.Revision == 65534; + /// + /// Gets a value indicating whether the current version is a Development build. + /// + public static bool IsDevelopment => new Version(0, 0, 0, 0) == AssemblyVersion; + /// /// Gets the path where application data is saved. /// @@ -288,6 +293,11 @@ namespace slskd logger.Information("Version: {Version}", FullVersion); + if (IsDevelopment) + { + logger.Warning("This is a Development build; YMMV"); + } + if (IsCanary) { logger.Warning("This is a canary build"); @@ -556,6 +566,11 @@ namespace slskd │ │ │{centeredVersion}│"; + if (IsDevelopment) + { + banner += "\n│■■■■■■■■■■■■■■■■■■■■► DEVELOPMENT ◄■■■■■■■■■■■■■■■■■■■■■│"; + } + if (IsCanary) { banner += "\n│■■■■■■■■■■■■■■■■■■■■■■■► CANARY ◄■■■■■■■■■■■■■■■■■■■■■■■│"; diff --git a/src/slskd/State.cs b/src/slskd/State.cs index afe9b0b1..d07c603a 100644 --- a/src/slskd/State.cs +++ b/src/slskd/State.cs @@ -43,6 +43,7 @@ namespace slskd public string Latest { get; init; } = null; public bool? IsUpdateAvailable { get; init; } = null; public bool IsCanary { get; init; } = Program.IsCanary; + public bool IsDevelopment { get; init; } = Program.IsDevelopment; } public record ServerState -- cgit v1.2.3