Skip to content

Commit

Permalink
fix version resolution (#173)
Browse files Browse the repository at this point in the history
  • Loading branch information
Crauzer authored Apr 11, 2023
1 parent ec21bd9 commit 6673402
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 14 deletions.
12 changes: 4 additions & 8 deletions Obsidian/Program.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using DiscordRPC;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection;
using MudBlazor;
using MudBlazor.Services;
using Obsidian.Data;
Expand All @@ -8,23 +7,20 @@
using PhotinoAPI;
using Semver;
using Serilog;
using System.Reflection;
using Toolbelt.Blazor.Extensions.DependencyInjection;

namespace Obsidian;

public class Program
{
public static readonly SemVersion VERSION = SemVersion.Parse("5.1.2", SemVersionStyles.Strict);

[STAThread]
static void Main(string[] args)
{
InitializeLogger();

SemVersion version = SemVersion.FromVersion(
Assembly.GetExecutingAssembly().GetName().Version
);
Log.Information($"Version: {version}");

Log.Information($"Version: {VERSION}");
Log.Information("Building app");

PhotinoBlazorAppBuilder builder = PhotinoBlazorAppBuilder.CreateDefault(args);
Expand Down
8 changes: 2 additions & 6 deletions Obsidian/Shared/MainLayout.razor
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
OnClick="GoToGithub" />
</MudTooltip>
<MudText Typo="Typo.body2">
@DisplayVersion
@Program.VERSION.ToString()
</MudText>
</MudStack>
</MudStack>
Expand Down Expand Up @@ -98,8 +98,6 @@

public string UpdateUrl { get; set; }

public string DisplayVersion => SemVersion.FromVersion(Version.Parse(FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).FileVersion)).ToString();

private bool _isLoadingHashtable;
private bool _isReady;

Expand Down Expand Up @@ -147,12 +145,10 @@
IReadOnlyList<Release> releases = await gitClient.Repository.Release.GetAll("Crauzer", "Obsidian");
Release newestRelease = releases[0];

FileVersionInfo versionInfo = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location);
SemVersion assemblySemver = SemVersion.FromVersion(Version.Parse(versionInfo.FileVersion));
SemVersion latestReleaseSemver = SemVersion.Parse(newestRelease.TagName, SemVersionStyles.Strict);

if (latestReleaseSemver.IsPrerelease is false
&& latestReleaseSemver.ComparePrecedenceTo(assemblySemver) > 0
&& latestReleaseSemver.ComparePrecedenceTo(Program.VERSION) > 0
)
{
Log.Information($"Found new update: {latestReleaseSemver}");
Expand Down

0 comments on commit 6673402

Please sign in to comment.