Embed commit hash into unstable builds
This commit is contained in:
parent
01d7f570fa
commit
87eda41001
3
.github/workflows/build.yml
vendored
3
.github/workflows/build.yml
vendored
@ -22,6 +22,9 @@ jobs:
|
||||
- name: Restore dependencies
|
||||
run: dotnet restore
|
||||
|
||||
- name: Embed version info
|
||||
run: echo "${{ github.sha }}" > ConfusedPolarBear.Plugin.IntroSkipper/Configuration/version.txt
|
||||
|
||||
- name: Build
|
||||
run: dotnet build --no-restore
|
||||
|
||||
|
@ -0,0 +1 @@
|
||||
unknown
|
@ -23,6 +23,7 @@
|
||||
<ItemGroup>
|
||||
<None Remove="Configuration\configPage.html" />
|
||||
<EmbeddedResource Include="Configuration\configPage.html" />
|
||||
<EmbeddedResource Include="Configuration\version.txt" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using Jellyfin.Data.Enums;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
@ -51,6 +52,10 @@ public class Entrypoint : IServerEntryPoint
|
||||
{
|
||||
Chromaprint.Logger = _logger;
|
||||
|
||||
#if DEBUG
|
||||
LogVersion();
|
||||
#endif
|
||||
|
||||
// Assert that ffmpeg with chromaprint is installed
|
||||
if (!Chromaprint.CheckFFmpegVersion())
|
||||
{
|
||||
@ -195,6 +200,40 @@ public class Entrypoint : IServerEntryPoint
|
||||
throw new FingerprintException("Unable to find an administrator on this server.");
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
/// <summary>
|
||||
/// Logs the exact commit that created this version of the plugin. Only used in unstable builds.
|
||||
/// </summary>
|
||||
private void LogVersion()
|
||||
{
|
||||
var assembly = GetType().Assembly;
|
||||
var path = GetType().Namespace + ".Configuration.version.txt";
|
||||
|
||||
using (var stream = assembly.GetManifestResourceStream(path))
|
||||
{
|
||||
if (stream is null)
|
||||
{
|
||||
_logger.LogWarning("Unable to read embedded version information");
|
||||
return;
|
||||
}
|
||||
|
||||
var version = string.Empty;
|
||||
using (var reader = new StreamReader(stream))
|
||||
{
|
||||
version = reader.ReadToEnd().TrimEnd();
|
||||
}
|
||||
|
||||
if (version == "unknown")
|
||||
{
|
||||
_logger.LogTrace("Embedded version information was not valid, ignoring");
|
||||
return;
|
||||
}
|
||||
|
||||
_logger.LogInformation("Unstable version built from commit {Version}", version);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Dispose.
|
||||
/// </summary>
|
||||
|
Loading…
x
Reference in New Issue
Block a user