Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,21 @@ jobs:
- name: Test boot script
run: node --test tests/boot/boot.test.mjs

# `signsofai --version` reported 0.1.0 for seven releases, because the number was restated in
# Program.cs instead of read from the build. Anyone checking whether they had a fix was told
# they were on the first release ever published. This runs the tool that was just built and
# compares what it says against the version the csproj packs, so the two cannot drift again.
- name: The CLI reports the version it was built as
run: |
want=$(grep -oPm1 '(?<=<Version>)[^<]+' src/SignsOfAI.Cli/SignsOfAI.Cli.csproj)
got=$(dotnet run --project src/SignsOfAI.Cli -c Release --no-build -- --version)
echo "csproj packs $want; the tool reports $got"
if [ "$want" != "$got" ]; then
echo "::error::signsofai --version says $got but this build is $want."
echo "Program.cs must read the version from the assembly, never restate it."
exit 1
fi

# The desktop app is WPF, so it needs a Windows runner and it is not in SignsOfAI.slnx — see the
# comment at the top of that file. Its own job keeps the build above on Linux, where it stays fast
# for the translation PRs that are the reason this workflow exists.
Expand Down
32 changes: 32 additions & 0 deletions src/SignsOfAI.Cli/BuildInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using System.Reflection;

namespace SignsOfAI.Cli;

/// <summary>
/// The version this build actually is, taken from the assembly the compiler stamped from
/// &lt;Version&gt; in the csproj. Restating it in source is how `--version` came to report 0.1.0
/// while the published package was 0.6.0 — seven releases of a tool telling people the wrong
/// answer to the one question they ask when a fix does not seem to be there.
/// </summary>
public static class BuildInfo
{
public static string Version { get; } = Read();

private static string Read()
{
var assembly = typeof(BuildInfo).Assembly;

// InformationalVersion carries the full "0.7.0+<sha>" when SourceLink is on; the build
// metadata after '+' is not part of the version people are asking about.
string? informational = assembly
.GetCustomAttribute<AssemblyInformationalVersionAttribute>()?.InformationalVersion;
if (!string.IsNullOrWhiteSpace(informational))
{
int plus = informational.IndexOf('+');
return plus < 0 ? informational : informational[..plus];
}

// A version with a trailing ".0" the csproj never wrote is still the truth about this build.
return assembly.GetName().Version?.ToString(3) ?? "unknown";
}
}
4 changes: 3 additions & 1 deletion src/SignsOfAI.Cli/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
using SignsOfAI.Core.Rules;

// ── signsofai: lint prose for the signs of AI writing ────────────────────────
const string Version = "0.1.0";
// Read from the assembly, never restated here: a constant went seven releases saying 0.1.0 while
// the package said 0.6.0, so anyone checking whether they had a fix was told they did not.
string Version = SignsOfAI.Cli.BuildInfo.Version;

// Emit UTF-8 so accents, · separators and glyphs render on Windows consoles too.
try { Console.OutputEncoding = System.Text.Encoding.UTF8; } catch { /* redirected / unsupported */ }
Expand Down
Loading