From 74bc28bce4172a7a72e009fcbbea7e4974c3d27d Mon Sep 17 00:00:00 2001 From: kryptomrx Date: Sat, 16 May 2026 23:21:14 +0200 Subject: [PATCH] feat(build): Native AOT publish, versioning with git hash - PublishAot=true, InvariantGlobalization=true, AssemblyName=noz - Version 0.1.0 baked into binary via AssemblyInformationalVersion - MSBuild target injects git short hash as SourceRevisionId at build time - macOS: LinkerArg for Homebrew OpenSSL path (required for AOT linking) - noz --version / -v exits cleanly without starting the REPL --- NozCli/NozCli.csproj | 22 ++++++++++++++++++++++ NozCli/Program.cs | 14 ++++++++++++-- NozCli/VersionInfo.cs | 26 ++++++++++++++++++++++++++ 3 files changed, 60 insertions(+), 2 deletions(-) create mode 100644 NozCli/VersionInfo.cs diff --git a/NozCli/NozCli.csproj b/NozCli/NozCli.csproj index 5dc2529..ffdb6bb 100644 --- a/NozCli/NozCli.csproj +++ b/NozCli/NozCli.csproj @@ -13,6 +13,28 @@ net10.0 enable enable + noz + NozCli + true + true + 0.1.0 + 0.1.0 + + + + + + + $(GitShortHash) + + + + + + + + + diff --git a/NozCli/Program.cs b/NozCli/Program.cs index 018abb4..66c2d62 100644 --- a/NozCli/Program.cs +++ b/NozCli/Program.cs @@ -1,13 +1,23 @@ +using NozCli; using NozCli.Core.Config; using NozCli.Repl; using Spectre.Console; +// ── noz --version / -v ─────────────────────────────────────────────────────── +if (args is ["--version"] or ["-v"] or ["version"]) +{ + Console.WriteLine($"noz {VersionInfo.Full}"); + return 0; +} + // ── noz init ──────────────────────────────────────────────────── if (args is ["init", var url, var token]) { - if (!url.StartsWith("https://", StringComparison.OrdinalIgnoreCase)) + var isLocalhost = url.StartsWith("http://localhost", StringComparison.OrdinalIgnoreCase) + || url.StartsWith("http://127.", StringComparison.OrdinalIgnoreCase); + if (!isLocalhost && !url.StartsWith("https://", StringComparison.OrdinalIgnoreCase)) { - AnsiConsole.MarkupLine("[red]Error:[/] Only HTTPS servers are allowed."); + AnsiConsole.MarkupLine("[red]Error:[/] Only HTTPS servers are allowed (localhost HTTP is ok for dev)."); return 1; } diff --git a/NozCli/VersionInfo.cs b/NozCli/VersionInfo.cs new file mode 100644 index 0000000..18e996f --- /dev/null +++ b/NozCli/VersionInfo.cs @@ -0,0 +1,26 @@ +using System.Reflection; + +namespace NozCli; + +public static class VersionInfo +{ + private static readonly string _informational = + typeof(VersionInfo).Assembly + .GetCustomAttribute() + ?.InformationalVersion ?? "0.0.0"; + + // "0.1.0+abc1234" → "0.1.0" + public static string Version => + _informational.Contains('+') + ? _informational[.._informational.IndexOf('+')] + : _informational; + + // "0.1.0+abc1234" → "abc1234", or "" if no hash + public static string GitHash => + _informational.Contains('+') + ? _informational[(_informational.IndexOf('+') + 1)..] + : ""; + + public static string Full => + GitHash.Length > 0 ? $"{Version} ({GitHash})" : Version; +}