From 13d67388119a89396f92297081d99e361ada30e9 Mon Sep 17 00:00:00 2001 From: Michael Fyffe <6224270+TraGicCode@users.noreply.github.com> Date: Mon, 17 Nov 2025 15:42:05 -0600 Subject: [PATCH] (GH-38) Fix --version/-v to contain actual cli version Closes #38 --- .github/workflows/docker_build.yml | 2 ++ build.cake | 3 +++ src/BuslyCLI.Console/BuslyCLI.Console.csproj | 2 ++ src/BuslyCLI.Console/Dockerfile | 5 ++++- src/BuslyCLI.Console/Spectre/AppConfiguration.cs | 4 +++- 5 files changed, 14 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker_build.yml b/.github/workflows/docker_build.yml index fc2c0c4..acaac5f 100644 --- a/.github/workflows/docker_build.yml +++ b/.github/workflows/docker_build.yml @@ -47,6 +47,8 @@ jobs: with: context: . file: ./src/BuslyCLI.Console/Dockerfile + build-args: | + APP_VERSION=${{ inputs.version }} push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} diff --git a/build.cake b/build.cake index e9eb0f7..4682cc4 100644 --- a/build.cake +++ b/build.cake @@ -27,9 +27,12 @@ Task("Compile") .IsDependentOn("Clean") .Does(() => { + var msBuildSettings = new DotNetMSBuildSettings() + .WithProperty("InformationalVersion", version); DotNetBuild(solution, new DotNetBuildSettings { Configuration = configuration, + MSBuildSettings = msBuildSettings, }); }); diff --git a/src/BuslyCLI.Console/BuslyCLI.Console.csproj b/src/BuslyCLI.Console/BuslyCLI.Console.csproj index 7f8795a..4a5056a 100644 --- a/src/BuslyCLI.Console/BuslyCLI.Console.csproj +++ b/src/BuslyCLI.Console/BuslyCLI.Console.csproj @@ -14,6 +14,8 @@ busly-logo-128x128.png https://github.com/TraGicCode/busly-cli git + 0.1.0 + false diff --git a/src/BuslyCLI.Console/Dockerfile b/src/BuslyCLI.Console/Dockerfile index 97a8075..65b9f62 100644 --- a/src/BuslyCLI.Console/Dockerfile +++ b/src/BuslyCLI.Console/Dockerfile @@ -1,5 +1,7 @@ # Use .NET 9 SDK to build FROM mcr.microsoft.com/dotnet/sdk:10.0.100 AS build + +ARG APP_VERSION=0.1.0 WORKDIR /src COPY Directory.Build.props ./ @@ -21,7 +23,8 @@ RUN dotnet publish "./BuslyCLI.Console/BuslyCLI.Console.csproj" \ -p:PublishTrimmed=true \ -p:TrimMode=partial \ -p:EnableCompressionInSingleFile=true \ - -p:SelfContained=true + -p:SelfContained=true \ + -p:InformationalVersion=$APP_VERSION # Use minimal runtime for smaller image size FROM mcr.microsoft.com/dotnet/runtime-deps:10.0-alpine AS final diff --git a/src/BuslyCLI.Console/Spectre/AppConfiguration.cs b/src/BuslyCLI.Console/Spectre/AppConfiguration.cs index 64ccfac..9c02dcf 100644 --- a/src/BuslyCLI.Console/Spectre/AppConfiguration.cs +++ b/src/BuslyCLI.Console/Spectre/AppConfiguration.cs @@ -1,3 +1,4 @@ +using System.Reflection; using BuslyCLI.Commands.Command; using BuslyCLI.Commands.Demo; using BuslyCLI.Commands.Event; @@ -14,7 +15,8 @@ public static Action GetSpectreCommandConfiguration() { config.SetApplicationName("busly"); // TODO: Allow this to get set via the CLI version - config.SetApplicationVersion("1.0.0"); + var assembly = Assembly.GetExecutingAssembly().GetCustomAttribute(); + config.SetApplicationVersion(assembly.InformationalVersion); config.AddBranch("transport", transport => { transport.SetDescription("Manage transport configurations.");