mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-12 18:27:23 +01:00
Merge pull request #1945 from KazWolfe/fixed-versioning
feat: Use new versioning strategy
This commit is contained in:
commit
bd170ee74a
12 changed files with 71 additions and 66 deletions
3
.github/workflows/main.yml
vendored
3
.github/workflows/main.yml
vendored
|
|
@ -137,6 +137,7 @@ jobs:
|
|||
|
||||
$newVersion = [System.IO.File]::ReadAllText("$(Get-Location)\scratch\TEMP_gitver.txt")
|
||||
$revision = [System.IO.File]::ReadAllText("$(Get-Location)\scratch\revision.txt")
|
||||
$commitHash = [System.IO.File]::ReadAllText("$(Get-Location)\scratch\commit_hash.txt")
|
||||
Remove-Item -Force -Recurse .\scratch
|
||||
|
||||
if (Test-Path -Path $branchName) {
|
||||
|
|
@ -147,7 +148,7 @@ jobs:
|
|||
} else {
|
||||
Move-Item -Force ".\canary.zip" ".\${branchName}\latest.zip"
|
||||
$versionData.AssemblyVersion = $newVersion
|
||||
$versionData | add-member -Force -Name "GitSha" $newVersion -MemberType NoteProperty
|
||||
$versionData | add-member -Force -Name "GitSha" $commitHash -MemberType NoteProperty
|
||||
$versionData | add-member -Force -Name "Revision" $revision -MemberType NoteProperty
|
||||
$versionData | ConvertTo-Json -Compress | Out-File ".\${branchName}\version"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -124,57 +124,45 @@
|
|||
<PropertyGroup>
|
||||
<!-- Needed temporarily for CI -->
|
||||
<TempVerFile>$(OutputPath)TEMP_gitver.txt</TempVerFile>
|
||||
<CommitHashFile>$(OutputPath)commit_hash.txt</CommitHashFile>
|
||||
<DalamudRevisionFile>$(OutputPath)revision.txt</DalamudRevisionFile>
|
||||
</PropertyGroup>
|
||||
|
||||
<Target Name="GetGitCommitCount" BeforeTargets="WriteGitHash" Condition="'$(CommitCount)'==''">
|
||||
<Target Name="GetVersionData" BeforeTargets="WriteVersionData" Condition="'$(SCMVersion)'=='' And '$(Configuration)'=='Release'">
|
||||
<Exec Command="git -C "$(ProjectDir.Replace('\','\\'))" rev-list --count HEAD" ConsoleToMSBuild="true">
|
||||
<Output TaskParameter="ConsoleOutput" PropertyName="DalamudGitCommitCount" />
|
||||
</Exec>
|
||||
|
||||
<!-- Set the BuildHash property to contain the GitVersion, if it wasn't already set.-->
|
||||
<PropertyGroup>
|
||||
<CommitCount>$([System.Text.RegularExpressions.Regex]::Replace($(DalamudGitCommitCount), @"\t|\n|\r", ""))</CommitCount>
|
||||
</PropertyGroup>
|
||||
|
||||
<Exec Command="echo|set /P ="$(CommitCount)" > $(DalamudRevisionFile)" IgnoreExitCode="true" />
|
||||
</Target>
|
||||
|
||||
<Target Name="GetGitHash" BeforeTargets="WriteGitHash" Condition="'$(BuildHash)'=='' And '$(Configuration)'=='Release'">
|
||||
<!-- write the hash to the temp file.-->
|
||||
<Exec Command="git -C "$(ProjectDir.Replace('\','\\'))" describe --long --tags --always --dirty" ConsoleToMSBuild="true">
|
||||
<Output TaskParameter="ConsoleOutput" PropertyName="DalamudGitDescribeOutput" />
|
||||
<Exec Command="git -C "$(ProjectDir.Replace('\','\\'))" describe --match=NeVeRmAtCh --always --abbrev=40 --dirty" ConsoleToMSBuild="true">
|
||||
<Output TaskParameter="ConsoleOutput" PropertyName="DalamudGitCommitHash" />
|
||||
</Exec>
|
||||
<Exec Command="git -C "$(ProjectDir.Replace('\','\\'))" rev-parse" ConsoleToMSBuild="true">
|
||||
<Output TaskParameter="ConsoleOutput" PropertyName="DalamudFullGitCommitHash" />
|
||||
<Exec Command="git -C "$(ProjectDir.Replace('\','\\'))" describe --tags --always --dirty" ConsoleToMSBuild="true">
|
||||
<Output TaskParameter="ConsoleOutput" PropertyName="DalamudGitDescribeOutput" />
|
||||
</Exec>
|
||||
<Exec Command="git -C "$(ProjectDir.Replace('\','\\'))\..\lib\FFXIVClientStructs" describe --long --always --dirty" ConsoleToMSBuild="true">
|
||||
<Output TaskParameter="ConsoleOutput" PropertyName="ClientStructsGitDescribeOutput" />
|
||||
</Exec>
|
||||
|
||||
<!-- Set the BuildHash property to contain the GitVersion, if it wasn't already set.-->
|
||||
<PropertyGroup>
|
||||
<BuildHash>$([System.Text.RegularExpressions.Regex]::Replace($(DalamudGitDescribeOutput), @"\t|\n|\r", ""))</BuildHash>
|
||||
<BuildHashClientStructs>$([System.Text.RegularExpressions.Regex]::Replace($(ClientStructsGitDescribeOutput), @"\t|\n|\r", ""))</BuildHashClientStructs>
|
||||
<CommitCount>$([System.Text.RegularExpressions.Regex]::Replace($(DalamudGitCommitCount), @"\t|\n|\r", ""))</CommitCount>
|
||||
<CommitHash>$([System.Text.RegularExpressions.Regex]::Replace($(DalamudGitCommitHash), @"\t|\n|\r", ""))</CommitHash>
|
||||
<SCMVersion>$([System.Text.RegularExpressions.Regex]::Replace($(DalamudGitDescribeOutput), @"\t|\n|\r", ""))</SCMVersion>
|
||||
<CommitHashClientStructs>$([System.Text.RegularExpressions.Regex]::Replace($(ClientStructsGitDescribeOutput), @"\t|\n|\r", ""))</CommitHashClientStructs>
|
||||
</PropertyGroup>
|
||||
|
||||
<!-- Looks like this is the only way to write a file without a carriage return in msbuild... -->
|
||||
<Exec Command="echo|set /P ="$(BuildHash)" > $(TempVerFile)" IgnoreExitCode="true" />
|
||||
<Exec Command="echo|set /P ="$(CommitCount)" > $(DalamudRevisionFile)" IgnoreExitCode="true" />
|
||||
<Exec Command="echo|set /P ="$(CommitHash)" > $(CommitHashFile)" IgnoreExitCode="true" />
|
||||
<Exec Command="echo|set /P ="$(SCMVersion)" > $(TempVerFile)" IgnoreExitCode="true" />
|
||||
</Target>
|
||||
|
||||
<Target Name="GetGitHashStub" BeforeTargets="WriteGitHash" Condition="'$(BuildHash)'=='' And '$(Configuration)'=='Debug'">
|
||||
<!-- Set the BuildHash property to contain some placeholder, if it wasn't already set.-->
|
||||
<Target Name="GenerateStubVersionData" BeforeTargets="WriteVersionData" Condition="'$(SCMVersion)'=='' And '$(Configuration)'!='Release'">
|
||||
<!-- stub out version since it takes a while. -->
|
||||
<PropertyGroup>
|
||||
<LocalBuildText>Local build at $([System.DateTime]::Now.ToString(yyyy-MM-dd HH:mm:ss))</LocalBuildText>
|
||||
<BuildHash>$(LocalBuildText)</BuildHash>
|
||||
<BuildHashClientStructs>???</BuildHashClientStructs>
|
||||
<SCMVersion>Local build at $([System.DateTime]::Now.ToString(yyyy-MM-dd HH:mm:ss))</SCMVersion>
|
||||
<CommitHashClientStructs>???</CommitHashClientStructs>
|
||||
</PropertyGroup>
|
||||
|
||||
<!-- Looks like this is the only way to write a file without a carriage return in msbuild... -->
|
||||
<Exec Command="echo|set /P ="$(BuildHash)" > $(TempVerFile)" IgnoreExitCode="true" />
|
||||
</Target>
|
||||
|
||||
<Target Name="WriteGitHash" BeforeTargets="CoreCompile">
|
||||
<Target Name="WriteVersionData" BeforeTargets="CoreCompile">
|
||||
<!-- names the obj/.../CustomAssemblyInfo.cs file -->
|
||||
<PropertyGroup>
|
||||
<CustomAssemblyInfoFile>$(IntermediateOutputPath)CustomAssemblyInfo.cs</CustomAssemblyInfoFile>
|
||||
|
|
@ -185,21 +173,21 @@
|
|||
</ItemGroup>
|
||||
<!-- defines the AssemblyMetadata attribute that will be written -->
|
||||
<ItemGroup>
|
||||
<AssemblyAttributes Include="AssemblyMetadata">
|
||||
<_Parameter1>GitHash</_Parameter1>
|
||||
<_Parameter2>$(BuildHash)</_Parameter2>
|
||||
<AssemblyAttributes Include="AssemblyMetadata" Condition="'$(SCMVersion)' != ''">
|
||||
<_Parameter1>SCMVersion</_Parameter1>
|
||||
<_Parameter2>$(SCMVersion)</_Parameter2>
|
||||
</AssemblyAttributes>
|
||||
<AssemblyAttributes Include="AssemblyMetadata">
|
||||
<AssemblyAttributes Include="AssemblyMetadata" Condition="'$(CommitCount)' != ''">
|
||||
<_Parameter1>GitCommitCount</_Parameter1>
|
||||
<_Parameter2>$(CommitCount)</_Parameter2>
|
||||
</AssemblyAttributes>
|
||||
<AssemblyAttributes Include="AssemblyMetadata">
|
||||
<AssemblyAttributes Include="AssemblyMetadata" Condition="'$(CommitHashClientStructs)' != ''">
|
||||
<_Parameter1>GitHashClientStructs</_Parameter1>
|
||||
<_Parameter2>$(BuildHashClientStructs)</_Parameter2>
|
||||
<_Parameter2>$(CommitHashClientStructs)</_Parameter2>
|
||||
</AssemblyAttributes>
|
||||
<AssemblyAttributes Include="AssemblyMetadata" Condition="'$(DalamudFullGitCommitHash)' != ''">
|
||||
<_Parameter1>FullGitHash</_Parameter1>
|
||||
<_Parameter2>$(DalamudFullGitCommitHash)</_Parameter2>
|
||||
<AssemblyAttributes Include="AssemblyMetadata" Condition="'$(CommitHash)' != ''">
|
||||
<_Parameter1>GitHash</_Parameter1>
|
||||
<_Parameter2>$(CommitHash)</_Parameter2>
|
||||
</AssemblyAttributes>
|
||||
</ItemGroup>
|
||||
<!-- writes the attribute to the customAssemblyInfo file -->
|
||||
|
|
|
|||
|
|
@ -187,7 +187,7 @@ public sealed class EntryPoint
|
|||
|
||||
var dalamud = new Dalamud(info, fs, configuration, mainThreadContinueEvent);
|
||||
Log.Information("This is Dalamud - Core: {GitHash}, CS: {CsGitHash} [{CsVersion}]",
|
||||
Util.GetGitHash(),
|
||||
Util.GetScmVersion(),
|
||||
Util.GetGitHashClientStructs(),
|
||||
FFXIVClientStructs.ThisAssembly.Git.Commits);
|
||||
|
||||
|
|
|
|||
|
|
@ -329,7 +329,7 @@ internal class DalamudCommands : IServiceType
|
|||
|
||||
chatGui.Print(new SeStringBuilder()
|
||||
.AddItalics("Dalamud:")
|
||||
.AddText($" D{Util.AssemblyVersion}({Util.GetGitHash()}")
|
||||
.AddText($" {Util.GetScmVersion()}")
|
||||
.Build());
|
||||
|
||||
chatGui.Print(new SeStringBuilder()
|
||||
|
|
|
|||
|
|
@ -842,9 +842,8 @@ internal class DalamudInterface : IInternalDisposableService
|
|||
this.OpenBranchSwitcher();
|
||||
}
|
||||
|
||||
ImGui.MenuItem(Util.AssemblyVersion, false);
|
||||
ImGui.MenuItem(this.dalamud.StartInfo.GameVersion?.ToString() ?? "Unknown version", false);
|
||||
ImGui.MenuItem($"D: {Util.GetGitHash()}[{Util.GetGitCommitCount()}] CS: {Util.GetGitHashClientStructs()}[{FFXIVClientStructs.ThisAssembly.Git.Commits}]", false);
|
||||
ImGui.MenuItem($"D: {Util.GetScmVersion()} CS: {Util.GetGitHashClientStructs()}[{FFXIVClientStructs.ThisAssembly.Git.Commits}]", false);
|
||||
ImGui.MenuItem($"CLR: {Environment.Version}", false);
|
||||
|
||||
ImGui.EndMenu();
|
||||
|
|
@ -1043,7 +1042,7 @@ internal class DalamudInterface : IInternalDisposableService
|
|||
{
|
||||
ImGui.PushFont(InterfaceManager.MonoFont);
|
||||
|
||||
ImGui.BeginMenu($"{Util.GetGitHash()}({Util.GetGitCommitCount()})", false);
|
||||
ImGui.BeginMenu(Util.GetScmVersion(), false);
|
||||
ImGui.BeginMenu(this.FrameCount.ToString("000000"), false);
|
||||
ImGui.BeginMenu(ImGui.GetIO().Framerate.ToString("000"), false);
|
||||
ImGui.BeginMenu($"W:{Util.FormatBytes(GC.GetTotalMemory(false))}", false);
|
||||
|
|
|
|||
|
|
@ -360,7 +360,7 @@ internal sealed class ChangelogWindow : Window, IDisposable
|
|||
{
|
||||
case State.WindowFadeIn:
|
||||
case State.ExplainerIntro:
|
||||
ImGui.TextWrapped($"Welcome to Dalamud v{Util.AssemblyVersion}!");
|
||||
ImGui.TextWrapped($"Welcome to Dalamud v{Util.GetScmVersion()}!");
|
||||
ImGuiHelpers.ScaledDummy(5);
|
||||
ImGui.TextWrapped(ChangeLog);
|
||||
ImGuiHelpers.ScaledDummy(5);
|
||||
|
|
|
|||
|
|
@ -305,7 +305,7 @@ internal class PluginInstallerWindow : Window, IDisposable
|
|||
return;
|
||||
|
||||
var versionInfo = t.Result;
|
||||
if (versionInfo.AssemblyVersion != Util.GetGitHash() &&
|
||||
if (versionInfo.AssemblyVersion != Util.GetScmVersion() &&
|
||||
versionInfo.Track != "release" &&
|
||||
string.Equals(versionInfo.Key, config.DalamudBetaKey, StringComparison.OrdinalIgnoreCase))
|
||||
this.staleDalamudNewVersion = versionInfo.AssemblyVersion;
|
||||
|
|
@ -1564,7 +1564,7 @@ internal class PluginInstallerWindow : Window, IDisposable
|
|||
DrawWarningIcon();
|
||||
DrawLinesCentered("A new version of Dalamud is available.\n" +
|
||||
"Please restart the game to ensure compatibility with updated plugins.\n" +
|
||||
$"old: {Util.GetGitHash()} new: {this.staleDalamudNewVersion}");
|
||||
$"old: {Util.GetScmVersion()} new: {this.staleDalamudNewVersion}");
|
||||
|
||||
ImGuiHelpers.ScaledDummy(10);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ internal class HappyHttpClient : IInternalDisposableService
|
|||
{
|
||||
UserAgent =
|
||||
{
|
||||
new ProductInfoHeaderValue("Dalamud", Util.AssemblyVersion),
|
||||
new ProductInfoHeaderValue("Dalamud", Util.GetScmVersion()),
|
||||
},
|
||||
},
|
||||
};
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ internal class PluginRepository
|
|||
},
|
||||
UserAgent =
|
||||
{
|
||||
new ProductInfoHeaderValue("Dalamud", Util.AssemblyVersion),
|
||||
new ProductInfoHeaderValue("Dalamud", Util.GetScmVersion()),
|
||||
},
|
||||
},
|
||||
};
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ internal static class BugBait
|
|||
Reporter = reporter,
|
||||
Name = plugin.InternalName,
|
||||
Version = isTesting ? plugin.TestingAssemblyVersion?.ToString() : plugin.AssemblyVersion.ToString(),
|
||||
DalamudHash = Util.GetGitHash(),
|
||||
DalamudHash = Util.GetScmVersion(),
|
||||
};
|
||||
|
||||
if (includeException)
|
||||
|
|
|
|||
|
|
@ -69,8 +69,8 @@ public static class Troubleshooting
|
|||
LoadedPlugins = pluginManager?.InstalledPlugins?.Select(x => x.Manifest as LocalPluginManifest)?.OrderByDescending(x => x.InternalName).ToArray(),
|
||||
PluginStates = pluginManager?.InstalledPlugins?.Where(x => !x.IsDev).ToDictionary(x => x.Manifest.InternalName, x => x.IsBanned ? "Banned" : x.State.ToString()),
|
||||
EverStartedLoadingPlugins = pluginManager?.InstalledPlugins.Where(x => x.HasEverStartedLoad).Select(x => x.InternalName).ToList(),
|
||||
DalamudVersion = Util.AssemblyVersion,
|
||||
DalamudGitHash = Util.GetGitHash(),
|
||||
DalamudVersion = Util.GetScmVersion(),
|
||||
DalamudGitHash = Util.GetGitHash() ?? "Unknown",
|
||||
GameVersion = startInfo.GameVersion?.ToString() ?? "Unknown",
|
||||
Language = startInfo.Language.ToString(),
|
||||
BetaKey = configuration.DalamudBetaKey,
|
||||
|
|
|
|||
|
|
@ -62,6 +62,7 @@ public static class Util
|
|||
];
|
||||
|
||||
private static readonly Type GenericSpanType = typeof(Span<>);
|
||||
private static string? scmVersionInternal;
|
||||
private static string? gitHashInternal;
|
||||
private static int? gitCommitCountInternal;
|
||||
private static string? gitHashClientStructsInternal;
|
||||
|
|
@ -128,11 +129,28 @@ public static class Util
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the git hash value from the assembly
|
||||
/// or null if it cannot be found.
|
||||
/// Gets the SCM Version from the assembly, or null if it cannot be found. This method will generally return
|
||||
/// the <c>git describe</c> output for this build, which will be a raw version if this is a stable build or an
|
||||
/// appropriately-annotated version if this is *not* stable. Local builds will return a `Local Build` text string.
|
||||
/// </summary>
|
||||
/// <returns>The SCM version of the assembly.</returns>
|
||||
public static string GetScmVersion()
|
||||
{
|
||||
if (scmVersionInternal != null) return scmVersionInternal;
|
||||
|
||||
var asm = typeof(Util).Assembly;
|
||||
var attrs = asm.GetCustomAttributes<AssemblyMetadataAttribute>();
|
||||
|
||||
return scmVersionInternal = attrs.First(a => a.Key == "SCMVersion").Value
|
||||
?? asm.GetName().Version!.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the git commit hash value from the assembly or null if it cannot be found. Will be null for Debug builds,
|
||||
/// and will be suffixed with `-dirty` if in release with pending changes.
|
||||
/// </summary>
|
||||
/// <returns>The git hash of the assembly.</returns>
|
||||
public static string GetGitHash()
|
||||
public static string? GetGitHash()
|
||||
{
|
||||
if (gitHashInternal != null)
|
||||
return gitHashInternal;
|
||||
|
|
@ -140,15 +158,14 @@ public static class Util
|
|||
var asm = typeof(Util).Assembly;
|
||||
var attrs = asm.GetCustomAttributes<AssemblyMetadataAttribute>();
|
||||
|
||||
gitHashInternal = attrs.First(a => a.Key == "GitHash").Value;
|
||||
|
||||
return gitHashInternal;
|
||||
return gitHashInternal = attrs.First(a => a.Key == "GitHash").Value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the amount of commits in the current branch, or null if undetermined.
|
||||
/// </summary>
|
||||
/// <returns>The amount of commits in the current branch.</returns>
|
||||
[Obsolete($"Planned for removal in API 11. Use {nameof(GetScmVersion)} for version tracking.")]
|
||||
public static int? GetGitCommitCount()
|
||||
{
|
||||
if (gitCommitCountInternal != null)
|
||||
|
|
@ -170,7 +187,7 @@ public static class Util
|
|||
/// or null if it cannot be found.
|
||||
/// </summary>
|
||||
/// <returns>The git hash of the assembly.</returns>
|
||||
public static string GetGitHashClientStructs()
|
||||
public static string? GetGitHashClientStructs()
|
||||
{
|
||||
if (gitHashClientStructsInternal != null)
|
||||
return gitHashClientStructsInternal;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue