Add NerdBank.GitVersioning support

This commit adds [NerdBank.GitVersioning](https://www.nuget.org/packages/Nerdbank.GitVersioning), which gives every build of plist-cil a unique version number.

The base version number is stored in `version.json` (e.g. 2.2) and is incremented by 1 every time a commit is added.  Builds off branches contain a `+g{commit}` suffix, indicating that these builds are prerelease.

This makes it easier to keep track of different versions of plist-cil.
This commit is contained in:
Frederik Carlier
2025-01-08 21:09:37 +01:00
parent a0b698a815
commit 0d30b8f444
3 changed files with 13 additions and 1 deletions

View File

@@ -23,10 +23,13 @@ jobs:
- name: Create NuGet packages - name: Create NuGet packages
run: | run: |
dotnet pack -c Release -o nuget/ dotnet pack -c Release -o nuget/
- name: Get version information
uses: dotnet/nbgv@master
id: nbgv
- name: Publish NuGet packages as artifacts - name: Publish NuGet packages as artifacts
uses: actions/upload-artifact@v3 uses: actions/upload-artifact@v3
with: with:
name: plist-cil name: plist-cil-${{ steps.nbgv.outputs.SemVer2 }}
path: nuget/ path: nuget/
- name: Publish NuGet packages to NuGet feed - name: Publish NuGet packages to NuGet feed
run: | run: |

View File

@@ -48,6 +48,7 @@ Add .NET 5.0 support.</PackageReleaseNotes>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All" /> <PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All" />
<PackageReference Include="Nerdbank.GitVersioning" Version="3.7.112" PrivateAssets="all" />
</ItemGroup> </ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net462'"> <ItemGroup Condition=" '$(TargetFramework)' == 'net462'">

8
version.json Normal file
View File

@@ -0,0 +1,8 @@
{
"$schema": "https://raw.githubusercontent.com/AArnott/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json",
"version": "2.2",
"publicReleaseRefSpec": [
"^refs/heads/master$",
"^refs/heads/releases/*"
]
}