Update CI to .NET 10, improve versioning and packaging

- Switch CI pipeline to use .NET 10.0 SDK images for build and publish jobs
- Set GIT_DEPTH=0 and fetch full git history for accurate versioning
- Refactor publish_nuget job to sanitize and inject GitVersion output into package version
- Downgrade GitVersion.MsBuild to 5.13.0 to match CLI tool version
- In csproj, set <Version> from sanitized GitVersion output with fallback
- Remove prevent-increment-of-merged-branch-version from GitVersion.yml for main/master
This commit is contained in:
MaddoScientisto 2026-02-15 18:42:35 +01:00
commit 25f41c1513
3 changed files with 23 additions and 15 deletions

View file

@ -5,8 +5,9 @@ stages:
variables: variables:
DOTNET_CLI_TELEMETRY_OPTOUT: "1" DOTNET_CLI_TELEMETRY_OPTOUT: "1"
DOTNET_NOLOGO: "true" DOTNET_NOLOGO: "true"
GIT_DEPTH: "0"
image: mcr.microsoft.com/dotnet/sdk:8.0 image: mcr.microsoft.com/dotnet/sdk:10.0
before_script: before_script:
- dotnet --info - dotnet --info
@ -23,17 +24,22 @@ build:
publish_nuget: publish_nuget:
stage: publish stage: publish
image: mcr.microsoft.com/dotnet/sdk:8.0 image: mcr.microsoft.com/dotnet/sdk:10.0
variables: variables:
NUGET_SOURCE: "$CI_API_V4_URL/projects/$CI_PROJECT_ID/packages/nuget/index.json" NUGET_SOURCE: "$CI_API_V4_URL/projects/$CI_PROJECT_ID/packages/nuget/index.json"
script: script: |
- dotnet restore dotnet restore
- dotnet tool install --global GitVersion.Tool --version 5.13.0 || true git fetch --prune --unshallow || true
- export PATH="$PATH:~/.dotnet/tools" git fetch origin +refs/heads/*:refs/remotes/origin/* || true
- gitversion /output buildserver git branch --show-current || true
- echo "GitVersion_NuGetVersionV2=$GitVersion_NuGetVersionV2" dotnet tool install --global GitVersion.Tool --version 5.13.0 || true
- dotnet pack src/AIFotoONLUS.Core/AIFotoONLUS.Core.csproj -c Release -o nuget --no-build export PATH="$PATH:~/.dotnet/tools"
- dotnet nuget push "nuget/*.nupkg" --source "$NUGET_SOURCE" --api-key "$CI_JOB_TOKEN" --skip-duplicate GITVER=$(gitversion /showvariable NuGetVersionV2)
echo "Raw version: $GITVER"
PACKAGE_VERSION=$(echo "$GITVER" | sed 's/[{}]//g' | sed 's/[^0-9A-Za-z.-]//g')
echo "Package version: $PACKAGE_VERSION"
dotnet pack src/AIFotoONLUS.Core/AIFotoONLUS.Core.csproj -c Release -o nuget /p:PackageVersion="$PACKAGE_VERSION"
dotnet nuget push "nuget/*.nupkg" --source "$NUGET_SOURCE" --api-key "$CI_JOB_TOKEN" --skip-duplicate
only: only:
- main - main
- master - master

View file

@ -3,12 +3,10 @@ branches:
main: main:
regex: ^main$ regex: ^main$
increment: Minor increment: Minor
prevent-increment-of-merged-branch-version: true
track-merge-target: false track-merge-target: false
master: master:
regex: ^master$ regex: ^master$
increment: Minor increment: Minor
prevent-increment-of-merged-branch-version: true
track-merge-target: false track-merge-target: false
feature: feature:
regex: ^(?:feat(?:ure)?|feature)[/\\-] regex: ^(?:feat(?:ure)?|feature)[/\\-]

View file

@ -11,8 +11,12 @@
<Company>Maddo</Company> <Company>Maddo</Company>
<Description>Core library for AIFotoONLUS image processing and recognition.</Description> <Description>Core library for AIFotoONLUS image processing and recognition.</Description>
<RepositoryUrl>https://gitlab.com/MaddoScientisto/aifotoonlus</RepositoryUrl> <RepositoryUrl>https://gitlab.com/MaddoScientisto/aifotoonlus</RepositoryUrl>
<!-- Use GitVersion MSBuild properties to set package version during CI/build --> <!-- Use GitVersion MSBuild properties to set package version during CI/build. Provide fallback if variable is not defined.
<Version>$(GitVersion_NuGetVersionV2)</Version> Sanitize the GitVersion output to remove characters invalid for NuGet (e.g., braces) -->
<GitVersionRaw>$(GitVersion_NuGetVersionV2)</GitVersionRaw>
<GitVersionSanitized>$([System.Text.RegularExpressions.Regex]::Replace('$(GitVersionRaw)','[{}]',''))</GitVersionSanitized>
<Version Condition="'$(GitVersionSanitized)' != ''">$(GitVersionSanitized)</Version>
<Version Condition="'$(GitVersionSanitized)' == ''">0.1.0</Version>
<PackageReleaseNotes>See Git history for release notes.</PackageReleaseNotes> <PackageReleaseNotes>See Git history for release notes.</PackageReleaseNotes>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild> <GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<IncludeSymbols>false</IncludeSymbols> <IncludeSymbols>false</IncludeSymbols>
@ -22,7 +26,7 @@
<PackageReference Include="OpenCvSharp4.runtime.win" Version="4.13.0.20260214" /> <PackageReference Include="OpenCvSharp4.runtime.win" Version="4.13.0.20260214" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="10.0.3" /> <PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="10.0.3" />
<!-- GitVersion MSBuild integration for automatic semantic versioning --> <!-- GitVersion MSBuild integration for automatic semantic versioning -->
<PackageReference Include="GitVersion.MsBuild" Version="6.5.1" PrivateAssets="all" /> <PackageReference Include="GitVersion.MsBuild" Version="5.13.0" PrivateAssets="all" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
</ItemGroup> </ItemGroup>