mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-12 21:38:38 +00:00
Removed BuildInfo constant
Indicate which version is currently installed in release list
This commit is contained in:
parent
1351796f42
commit
0852769cc9
@ -62,9 +62,16 @@ public static class Constants
|
||||
/// <summary>
|
||||
/// The current API version for plugins
|
||||
/// </summary>
|
||||
public static readonly int PluginApiVersion = int.Parse(CoreAssembly.GetCustomAttributes<AssemblyMetadataAttribute>().First(a => a.Key == "PluginApiVersion").Value ??
|
||||
public static readonly int PluginApiVersion = int.Parse(CoreAssembly.GetCustomAttributes<AssemblyMetadataAttribute>().FirstOrDefault(a => a.Key == "PluginApiVersion")?.Value ??
|
||||
throw new InvalidOperationException("Cannot find PluginApiVersion metadata in assembly"));
|
||||
|
||||
/// <summary>
|
||||
/// The current version of the application
|
||||
/// </summary>
|
||||
public static readonly string CurrentVersion = CoreAssembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>()!.InformationalVersion != "1.0.0"
|
||||
? CoreAssembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>()!.InformationalVersion
|
||||
: "1.2023.0212.2-feature-gh-actions";
|
||||
|
||||
/// <summary>
|
||||
/// The plugin info used by core components of Artemis
|
||||
/// </summary>
|
||||
@ -73,21 +80,6 @@ public static class Constants
|
||||
Guid = Guid.Parse("ffffffff-ffff-ffff-ffff-ffffffffffff"), Name = "Artemis Core", Version = new Version(2, 0)
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// The build information related to the currently running Artemis build
|
||||
/// <para>Information is retrieved from <c>buildinfo.json</c></para>
|
||||
/// </summary>
|
||||
public static readonly BuildInfo BuildInfo = File.Exists(Path.Combine(ApplicationFolder, "buildinfo.json"))
|
||||
? JsonConvert.DeserializeObject<BuildInfo>(File.ReadAllText(Path.Combine(ApplicationFolder, "buildinfo.json")))!
|
||||
: new BuildInfo
|
||||
{
|
||||
IsLocalBuild = true,
|
||||
BuildId = 1337,
|
||||
BuildNumber = 1337,
|
||||
SourceBranch = "local",
|
||||
SourceVersion = "local"
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// The plugin used by core components of Artemis
|
||||
/// </summary>
|
||||
|
||||
@ -200,23 +200,17 @@ internal class CoreService : ICoreService
|
||||
if (IsInitialized)
|
||||
throw new ArtemisCoreException("Cannot initialize the core as it is already initialized.");
|
||||
|
||||
AssemblyInformationalVersionAttribute? versionAttribute = typeof(CoreService).Assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>();
|
||||
_logger.Information(
|
||||
"Initializing Artemis Core version {version}, build {buildNumber} branch {branch}.",
|
||||
versionAttribute?.InformationalVersion,
|
||||
Constants.BuildInfo.BuildNumber,
|
||||
Constants.BuildInfo.SourceBranch
|
||||
);
|
||||
_logger.Information("Startup arguments: {args}", Constants.StartupArguments);
|
||||
_logger.Information("Elevated permissions: {perms}", IsElevated);
|
||||
_logger.Information("Stopwatch high resolution: {perms}", Stopwatch.IsHighResolution);
|
||||
_logger.Information("Initializing Artemis Core version {CurrentVersion}", Constants.CurrentVersion);
|
||||
_logger.Information("Startup arguments: {StartupArguments}", Constants.StartupArguments);
|
||||
_logger.Information("Elevated permissions: {IsElevated}", IsElevated);
|
||||
_logger.Information("Stopwatch high resolution: {IsHighResolution}", Stopwatch.IsHighResolution);
|
||||
|
||||
ApplyLoggingLevel();
|
||||
|
||||
// Don't remove even if it looks useless
|
||||
// Just this line should prevent a certain someone from removing HidSharp as an unused dependency as well
|
||||
Version? hidSharpVersion = Assembly.GetAssembly(typeof(HidDevice))!.GetName().Version;
|
||||
_logger.Debug("Forcing plugins to use HidSharp {hidSharpVersion}", hidSharpVersion);
|
||||
_logger.Debug("Forcing plugins to use HidSharp {HidSharpVersion}", hidSharpVersion);
|
||||
|
||||
// Initialize the services
|
||||
_pluginManagementService.CopyBuiltInPlugins();
|
||||
|
||||
@ -111,7 +111,7 @@ public class AutoRunProvider : IAutoRunProvider
|
||||
/// <inheritdoc />
|
||||
public async Task EnableAutoRun(bool recreate, int autoRunDelay)
|
||||
{
|
||||
if (Constants.BuildInfo.IsLocalBuild)
|
||||
if (Constants.CurrentVersion == "development")
|
||||
return;
|
||||
|
||||
await CleanupOldAutorun();
|
||||
|
||||
@ -57,7 +57,7 @@ public class AboutTabViewModel : ActivatableViewModelBase
|
||||
private async Task Activate()
|
||||
{
|
||||
AssemblyInformationalVersionAttribute? versionAttribute = typeof(AboutTabViewModel).Assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>();
|
||||
Version = $"Version {versionAttribute?.InformationalVersion} build {Constants.BuildInfo.BuildNumberDisplay}";
|
||||
Version = $"Version {Constants.CurrentVersion}";
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
@ -4,6 +4,7 @@
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:settings="clr-namespace:Artemis.UI.Screens.Settings"
|
||||
xmlns:updating="clr-namespace:Artemis.UI.Screens.Settings.Updating"
|
||||
xmlns:avalonia="clr-namespace:Material.Icons.Avalonia;assembly=Material.Icons.Avalonia"
|
||||
mc:Ignorable="d" d:DesignWidth="1000" d:DesignHeight="1400"
|
||||
x:Class="Artemis.UI.Screens.Settings.ReleasesTabView"
|
||||
x:DataType="settings:ReleasesTabViewModel">
|
||||
@ -12,15 +13,29 @@
|
||||
<ListBox Items="{CompiledBinding ReleaseViewModels}" SelectedItem="{CompiledBinding SelectedReleaseViewModel}">
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate x:DataType="updating:ReleaseViewModel">
|
||||
<StackPanel Margin="4">
|
||||
<TextBlock Text="{CompiledBinding Version}" VerticalAlignment="Center" />
|
||||
<TextBlock Text="{CompiledBinding CreatedAt, StringFormat={}{0:g}}" VerticalAlignment="Center" Classes="subtitle" FontSize="13" />
|
||||
</StackPanel>
|
||||
<Panel>
|
||||
<Grid Margin="4" IsVisible="{CompiledBinding IsCurrentVersion}" RowDefinitions="*,*" ColumnDefinitions="*,Auto">
|
||||
<TextBlock Grid.Row="0" Grid.Column="0" Text="{CompiledBinding Version}" VerticalAlignment="Center" IsVisible="{CompiledBinding IsCurrentVersion}" FontWeight="SemiBold" />
|
||||
<TextBlock Grid.Row="1" Grid.Column="0" Text="{CompiledBinding CreatedAt, StringFormat={}{0:g}}" VerticalAlignment="Center" Classes="subtitle" FontSize="13" />
|
||||
<avalonia:MaterialIcon Grid.Row="0"
|
||||
Grid.Column="1"
|
||||
Grid.RowSpan="2"
|
||||
Kind="CheckCircle"
|
||||
ToolTip.Tip="Currently installed"
|
||||
Foreground="{DynamicResource SystemAccentColorLight3}"
|
||||
Width="20"
|
||||
Height="20" />
|
||||
</Grid>
|
||||
<StackPanel Margin="4" IsVisible="{CompiledBinding !IsCurrentVersion}">
|
||||
<TextBlock Text="{CompiledBinding Version}" VerticalAlignment="Center" />
|
||||
<TextBlock Text="{CompiledBinding CreatedAt, StringFormat={}{0:g}}" VerticalAlignment="Center" Classes="subtitle" FontSize="13" />
|
||||
</StackPanel>
|
||||
</Panel>
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
</Border>
|
||||
|
||||
<ContentControl Grid.Column="1" Content="{CompiledBinding SelectedReleaseViewModel}"/>
|
||||
<ContentControl Grid.Column="1" Content="{CompiledBinding SelectedReleaseViewModel}" />
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@ -61,6 +61,7 @@ public class ReleaseViewModel : ActivatableViewModelBase
|
||||
else
|
||||
throw new PlatformNotSupportedException("Cannot auto update on the current platform");
|
||||
|
||||
|
||||
ReleaseId = releaseId;
|
||||
Version = version;
|
||||
CreatedAt = createdAt;
|
||||
@ -144,6 +145,8 @@ public class ReleaseViewModel : ActivatableViewModelBase
|
||||
set => RaiseAndSetIfChanged(ref _installationFinished, value);
|
||||
}
|
||||
|
||||
public bool IsCurrentVersion => Version == Constants.CurrentVersion;
|
||||
|
||||
public void NavigateToSource()
|
||||
{
|
||||
Utilities.OpenUrl($"https://github.com/Artemis-RGB/Artemis/commit/{Commit}");
|
||||
|
||||
@ -25,29 +25,29 @@ public class StartupWizardViewModel : DialogViewModelBase<bool>
|
||||
private readonly IAutoRunProvider? _autoRunProvider;
|
||||
private readonly IRgbService _rgbService;
|
||||
private readonly ISettingsService _settingsService;
|
||||
private readonly IUpdateService _updateService;
|
||||
private readonly IWindowService _windowService;
|
||||
private int _currentStep;
|
||||
private bool _showContinue;
|
||||
private bool _showFinish;
|
||||
private bool _showGoBack;
|
||||
|
||||
public StartupWizardViewModel(IContainer container, ISettingsService settingsService, IRgbService rgbService, IPluginManagementService pluginManagementService, IWindowService windowService,
|
||||
IUpdateService updateService, ISettingsVmFactory settingsVmFactory)
|
||||
public StartupWizardViewModel(IContainer container,
|
||||
ISettingsService settingsService,
|
||||
IRgbService rgbService,
|
||||
IPluginManagementService pluginManagementService,
|
||||
IWindowService windowService,
|
||||
ISettingsVmFactory settingsVmFactory)
|
||||
{
|
||||
_settingsService = settingsService;
|
||||
_rgbService = rgbService;
|
||||
_windowService = windowService;
|
||||
_updateService = updateService;
|
||||
_autoRunProvider = container.Resolve<IAutoRunProvider>(IfUnresolved.ReturnDefault);
|
||||
|
||||
Continue = ReactiveCommand.Create(ExecuteContinue);
|
||||
GoBack = ReactiveCommand.Create(ExecuteGoBack);
|
||||
SkipOrFinishWizard = ReactiveCommand.Create(ExecuteSkipOrFinishWizard);
|
||||
SelectLayout = ReactiveCommand.Create<string>(ExecuteSelectLayout);
|
||||
|
||||
AssemblyInformationalVersionAttribute? versionAttribute = typeof(StartupWizardViewModel).Assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>();
|
||||
Version = $"Version {versionAttribute?.InformationalVersion} build {Constants.BuildInfo.BuildNumberDisplay}";
|
||||
Version = $"Version {Constants.CurrentVersion}";
|
||||
|
||||
// Take all compatible plugins that have an always-enabled device provider
|
||||
DeviceProviders = new ObservableCollection<PluginViewModel>(pluginManagementService.GetAllPlugins()
|
||||
|
||||
@ -6,7 +6,6 @@ namespace Artemis.UI.Services.Updating;
|
||||
|
||||
public interface IUpdateService : IArtemisUIService
|
||||
{
|
||||
string? CurrentVersion { get; }
|
||||
IGetNextRelease_NextPublishedRelease? CachedLatestRelease { get; }
|
||||
|
||||
Task CacheLatestRelease();
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Artemis.Core;
|
||||
@ -8,7 +7,6 @@ using Artemis.Storage.Entities.General;
|
||||
using Artemis.Storage.Repositories.Interfaces;
|
||||
using Artemis.UI.Shared.Services.MainWindow;
|
||||
using Artemis.WebClient.Updating;
|
||||
using Avalonia.Threading;
|
||||
using Serilog;
|
||||
using StrawberryShake;
|
||||
using Timer = System.Timers.Timer;
|
||||
@ -113,25 +111,16 @@ public class UpdateService : IUpdateService
|
||||
|
||||
public IGetNextRelease_NextPublishedRelease? CachedLatestRelease { get; private set; }
|
||||
|
||||
public string? CurrentVersion
|
||||
{
|
||||
get
|
||||
{
|
||||
object[] attributes = typeof(UpdateService).Assembly.GetCustomAttributes(typeof(AssemblyInformationalVersionAttribute), false);
|
||||
return attributes.Length == 0 ? null : ((AssemblyInformationalVersionAttribute) attributes[0]).InformationalVersion;
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task CacheLatestRelease()
|
||||
{
|
||||
IOperationResult<IGetNextReleaseResult> result = await _updatingClient.GetNextRelease.ExecuteAsync(CurrentVersion, _channel.Value, _updatePlatform);
|
||||
IOperationResult<IGetNextReleaseResult> result = await _updatingClient.GetNextRelease.ExecuteAsync(Constants.CurrentVersion, _channel.Value, _updatePlatform);
|
||||
CachedLatestRelease = result.Data?.NextPublishedRelease;
|
||||
}
|
||||
|
||||
public async Task<bool> CheckForUpdate()
|
||||
{
|
||||
IOperationResult<IGetNextReleaseResult> result = await _updatingClient.GetNextRelease.ExecuteAsync(CurrentVersion, _channel.Value, _updatePlatform);
|
||||
IOperationResult<IGetNextReleaseResult> result = await _updatingClient.GetNextRelease.ExecuteAsync(Constants.CurrentVersion, _channel.Value, _updatePlatform);
|
||||
result.EnsureNoErrors();
|
||||
|
||||
// Update cache
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user