Skip to content

Commit df625bc

Browse files
authored
dotnet.yml: Use auto versioning via nerdbank.gitversioning, and update CI pipeline with release pipeline (#158)
1 parent 0e2f4f1 commit df625bc

File tree

19 files changed

+219
-30
lines changed

19 files changed

+219
-30
lines changed

.github/workflows/dotnet.yml

Lines changed: 100 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,23 @@
22

33
name: dotnet
44

5+
permissions: read-all
6+
57
on:
68
push:
79
branches: [ "master" ]
810
pull_request:
911
branches: [ "master" ]
10-
# workflow_dispatch:
11-
# inputs:
12-
# version:
13-
# description: 'Release version to tag and create'
14-
# required: false
12+
workflow_dispatch:
13+
inputs:
14+
version:
15+
description: 'Release version to tag and create'
16+
required: false
1517

1618
env:
1719
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
1820
DOTNET_NOLOGO: true
21+
NuGetDirectory: ${{ github.workspace }}/nuget
1922

2023
jobs:
2124
build:
@@ -28,6 +31,8 @@ jobs:
2831

2932
steps:
3033
- uses: actions/checkout@v3
34+
with:
35+
fetch-depth: 0 # Important for Nerdbank.GitVersioning to calculate versions
3136
- name: Setup .NET
3237
uses: actions/setup-dotnet@v3
3338
with:
@@ -37,8 +42,93 @@ jobs:
3742
- name: Build
3843
run: dotnet build -c ${{ matrix.configuration }} --no-restore
3944
- name: Test
40-
run: dotnet test -c ${{ matrix.configuration }} --no-build --verbosity normal
41-
# - name: Upload coverage reports to Codecov
42-
# uses: codecov/codecov-action@v3
43-
# with:
44-
# flags: ${{ matrix.os }},${{ matrix.configuration }}
45+
run: dotnet test -c ${{ matrix.configuration }} --no-build --verbosity normal --collect:"XPlat Code Coverage"
46+
- name: Upload coverage reports to Codecov
47+
uses: codecov/codecov-action@v3
48+
with:
49+
flags: ${{ matrix.os }},${{ matrix.configuration }}
50+
51+
format:
52+
strategy:
53+
matrix:
54+
os: [ubuntu-latest]
55+
56+
runs-on: ${{ matrix.os }}
57+
58+
steps:
59+
- uses: actions/checkout@v3
60+
- name: Setup .NET
61+
uses: actions/setup-dotnet@v3
62+
with:
63+
global-json-file: global.json
64+
- name: Format verify no changes
65+
run: dotnet format --verify-no-changes
66+
67+
pack:
68+
runs-on: windows-latest
69+
steps:
70+
- uses: actions/checkout@v3
71+
with:
72+
fetch-depth: 0 # Important for Nerdbank.GitVersioning to calculate versions
73+
- name: Setup .NET
74+
uses: actions/setup-dotnet@v3
75+
with:
76+
global-json-file: global.json
77+
- name: Pack solution
78+
run: dotnet pack SharpLearning.sln -c Release --output ${{ env.NuGetDirectory }}
79+
- name: Add local package source
80+
run: dotnet nuget add source ${{ env.NuGetDirectory }} --name local
81+
- name: Get version of dll
82+
run: (Get-Item './build/SharpLearning.AdaBoost_AnyCPU_Release_netstandard2.0/SharpLearning.AdaBoost.dll').VersionInfo.ProductVersion # unified version, so use AdaBoost dll.
83+
- uses: actions/upload-artifact@v4
84+
with:
85+
name: nuget
86+
if-no-files-found: error
87+
retention-days: 7
88+
path: ${{ env.NuGetDirectory }}/*nupkg
89+
90+
create-release-push:
91+
needs: [ build, pack ]
92+
runs-on: windows-latest
93+
permissions:
94+
contents: write
95+
if: ${{ github.event.inputs.version != '' && github.actor == 'mdabros'}}
96+
97+
steps:
98+
- uses: actions/checkout@v3
99+
- name: Download nuget packages
100+
uses: actions/download-artifact@v4
101+
with:
102+
name: nuget
103+
path: ${{ env.NuGetDirectory }}
104+
- name: Create release
105+
id: create_release
106+
uses: actions/create-release@v1
107+
env:
108+
GITHUB_TOKEN: ${{ secrets.ACTION_GITHUB_TOKEN }}
109+
with:
110+
tag_name: v${{ github.event.inputs.version }}
111+
release_name: ${{ github.event.inputs.version }}
112+
draft: true
113+
- name: Create tag (for release)
114+
run: |
115+
git tag v${{ github.event.inputs.version }}
116+
git push origin v${{ github.event.inputs.version }}
117+
- name: Upload NuGet packages
118+
uses: actions/upload-release-asset@v1
119+
env:
120+
GITHUB_TOKEN: ${{ secrets.ACTION_GITHUB_TOKEN }}
121+
with:
122+
upload_url: ${{ steps.create_release.outputs.upload_url }}
123+
asset_path: ${{ env.NuGetDirectory }}/*.nupkg
124+
asset_name: ${{ env.NuGetDirectory }}/*.nupkg
125+
asset_content_type: application/zip
126+
- name: Setup .NET
127+
uses: actions/setup-dotnet@v3
128+
with:
129+
global-json-file: global.json
130+
- name: Push NuGet packages
131+
run: |
132+
for package in ${{ env.NuGetDirectory }}/*.nupkg; do
133+
dotnet nuget push "$package" --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate
134+
done

SharpLearning.sln

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "root", "root", "{D83436F7-2
7171
global.json = global.json
7272
LICENSE = LICENSE
7373
README.md = README.md
74+
version.json = version.json
7475
EndProjectSection
7576
EndProject
7677
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{2204FA16-973A-48CF-A9FD-94FA72424BA4}"

src/Directory.Build.props

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
<Project>
22
<PropertyGroup>
3-
<AssemblyVersion>0.31.0</AssemblyVersion>
4-
<FileVersion>0.31.10</FileVersion>
5-
<InformationalVersion>$(FileVersion)</InformationalVersion>
6-
<PackageVersion>$(InformationalVersion)</PackageVersion>
73
<!--https://github.com/dotnet/sourcelink/blob/main/docs/README.md#includesourcerevisionininformationalversion-->
84
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
95

src/SharpLearning.AdaBoost/SharpLearning.AdaBoost.csproj

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,11 @@
1515
<ProjectReference Include="..\SharpLearning.Metrics\SharpLearning.Metrics.csproj" />
1616
</ItemGroup>
1717

18+
<ItemGroup>
19+
<PackageReference Include="Nerdbank.GitVersioning" Version="3.6.139">
20+
<PrivateAssets>all</PrivateAssets>
21+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
22+
</PackageReference>
23+
</ItemGroup>
24+
1825
</Project>

src/SharpLearning.Common.Interfaces/SharpLearning.Common.Interfaces.csproj

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,11 @@
1010
<ProjectReference Include="..\SharpLearning.Containers\SharpLearning.Containers.csproj" />
1111
</ItemGroup>
1212

13+
<ItemGroup>
14+
<PackageReference Include="Nerdbank.GitVersioning" Version="3.6.139">
15+
<PrivateAssets>all</PrivateAssets>
16+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
17+
</PackageReference>
18+
</ItemGroup>
19+
1320
</Project>

src/SharpLearning.Containers/SharpLearning.Containers.csproj

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,11 @@
77
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
88
</PropertyGroup>
99

10+
<ItemGroup>
11+
<PackageReference Include="Nerdbank.GitVersioning" Version="3.6.139">
12+
<PrivateAssets>all</PrivateAssets>
13+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
14+
</PackageReference>
15+
</ItemGroup>
16+
1017
</Project>

src/SharpLearning.CrossValidation/SharpLearning.CrossValidation.csproj

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,11 @@
1717
<ProjectReference Include="..\SharpLearning.InputOutput\SharpLearning.InputOutput.csproj" />
1818
</ItemGroup>
1919

20+
<ItemGroup>
21+
<PackageReference Include="Nerdbank.GitVersioning" Version="3.6.139">
22+
<PrivateAssets>all</PrivateAssets>
23+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
24+
</PackageReference>
25+
</ItemGroup>
26+
2027
</Project>

src/SharpLearning.DecisionTrees/SharpLearning.DecisionTrees.csproj

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,11 @@
1414
<ProjectReference Include="..\SharpLearning.InputOutput\SharpLearning.InputOutput.csproj" />
1515
</ItemGroup>
1616

17+
<ItemGroup>
18+
<PackageReference Include="Nerdbank.GitVersioning" Version="3.6.139">
19+
<PrivateAssets>all</PrivateAssets>
20+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
21+
</PackageReference>
22+
</ItemGroup>
23+
1724
</Project>

src/SharpLearning.Ensemble/SharpLearning.Ensemble.csproj

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,11 @@
1515
<ProjectReference Include="..\SharpLearning.Metrics\SharpLearning.Metrics.csproj" />
1616
</ItemGroup>
1717

18+
<ItemGroup>
19+
<PackageReference Include="Nerdbank.GitVersioning" Version="3.6.139">
20+
<PrivateAssets>all</PrivateAssets>
21+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
22+
</PackageReference>
23+
</ItemGroup>
24+
1825
</Project>

src/SharpLearning.FeatureTransformations/SharpLearning.FeatureTransformations.csproj

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,11 @@
1212
<ProjectReference Include="..\SharpLearning.InputOutput\SharpLearning.InputOutput.csproj" />
1313
</ItemGroup>
1414

15+
<ItemGroup>
16+
<PackageReference Include="Nerdbank.GitVersioning" Version="3.6.139">
17+
<PrivateAssets>all</PrivateAssets>
18+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
19+
</PackageReference>
20+
</ItemGroup>
21+
1522
</Project>

src/SharpLearning.GradientBoost/SharpLearning.GradientBoost.csproj

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,11 @@
1414
<ProjectReference Include="..\SharpLearning.InputOutput\SharpLearning.InputOutput.csproj" />
1515
</ItemGroup>
1616

17+
<ItemGroup>
18+
<PackageReference Include="Nerdbank.GitVersioning" Version="3.6.139">
19+
<PrivateAssets>all</PrivateAssets>
20+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
21+
</PackageReference>
22+
</ItemGroup>
23+
1724
</Project>

src/SharpLearning.InputOutput/SharpLearning.InputOutput.csproj

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,11 @@
1111
<ProjectReference Include="..\SharpLearning.Containers\SharpLearning.Containers.csproj" />
1212
</ItemGroup>
1313

14+
<ItemGroup>
15+
<PackageReference Include="Nerdbank.GitVersioning" Version="3.6.139">
16+
<PrivateAssets>all</PrivateAssets>
17+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
18+
</PackageReference>
19+
</ItemGroup>
20+
1421
</Project>

src/SharpLearning.Metrics/SharpLearning.Metrics.csproj

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,11 @@
1212
<ProjectReference Include="..\SharpLearning.Containers\SharpLearning.Containers.csproj" />
1313
</ItemGroup>
1414

15+
<ItemGroup>
16+
<PackageReference Include="Nerdbank.GitVersioning" Version="3.6.139">
17+
<PrivateAssets>all</PrivateAssets>
18+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
19+
</PackageReference>
20+
</ItemGroup>
21+
1522
</Project>

src/SharpLearning.Neural/SharpLearning.Neural.csproj

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,19 @@
1111
<PackageTags>neural network convolutional deep learning machine-learning classification regression</PackageTags>
1212
</PropertyGroup>
1313

14-
<ItemGroup>
15-
<PackageReference Include="MathNet.Numerics" Version="4.8.1" />
16-
<PackageReference Include="MathNet.Numerics.MKL.Win" Version="2.3.0" />
17-
</ItemGroup>
18-
1914
<ItemGroup>
2015
<ProjectReference Include="..\SharpLearning.Common.Interfaces\SharpLearning.Common.Interfaces.csproj" />
2116
<ProjectReference Include="..\SharpLearning.Containers\SharpLearning.Containers.csproj" />
2217
<ProjectReference Include="..\SharpLearning.InputOutput\SharpLearning.InputOutput.csproj" />
2318
</ItemGroup>
2419

20+
<ItemGroup>
21+
<PackageReference Include="Nerdbank.GitVersioning" Version="3.6.139">
22+
<PrivateAssets>all</PrivateAssets>
23+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
24+
</PackageReference>
25+
<PackageReference Include="MathNet.Numerics" Version="4.8.1" />
26+
<PackageReference Include="MathNet.Numerics.MKL.Win" Version="2.3.0" />
27+
</ItemGroup>
28+
2529
</Project>

src/SharpLearning.Optimization.Test/GlobalizedBoundedNelderMeadOptimizerTest.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,10 @@ public void GlobalizedBoundedNelderMeadOptimizer_OptimizeBest(int? maxDegreeOfPa
2828
Assert.AreEqual(expected: -0.99999960731425908, actual.Error, Delta);
2929
Assert.AreEqual(expected: 3, actual.ParameterSet.Length);
3030

31-
Assert.AreEqual(expected: -1.5711056814954487, actual.ParameterSet[0], Delta);
32-
Assert.AreEqual(expected: -6.283490634742785, actual.ParameterSet[1], Delta);
33-
Assert.AreEqual(expected: -2.9822323517533149E-07, actual.ParameterSet[2], Delta);
31+
const double delta = 1e-3;
32+
Assert.AreEqual(expected: -1.5711056814954487, actual.ParameterSet[0], delta);
33+
Assert.AreEqual(expected: -6.283490634742785, actual.ParameterSet[1], delta);
34+
Assert.AreEqual(expected: -2.9822323517533149E-07, actual.ParameterSet[2], delta);
3435
}
3536

3637
[TestMethod]

src/SharpLearning.Optimization/SharpLearning.Optimization.csproj

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,17 @@
77
<PackageTags>optimization grid search random particle swarm nelder-mead bayesian-optimization machine-learning</PackageTags>
88
</PropertyGroup>
99

10-
<ItemGroup>
11-
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
12-
</ItemGroup>
13-
1410
<ItemGroup>
1511
<ProjectReference Include="..\SharpLearning.Common.Interfaces\SharpLearning.Common.Interfaces.csproj" />
1612
<ProjectReference Include="..\SharpLearning.Containers\SharpLearning.Containers.csproj" />
1713
<ProjectReference Include="..\SharpLearning.RandomForest\SharpLearning.RandomForest.csproj" />
1814
</ItemGroup>
1915

16+
<ItemGroup>
17+
<PackageReference Include="Nerdbank.GitVersioning" Version="3.6.139">
18+
<PrivateAssets>all</PrivateAssets>
19+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
20+
</PackageReference>
21+
</ItemGroup>
22+
2023
</Project>

src/SharpLearning.RandomForest/SharpLearning.RandomForest.csproj

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,11 @@
1414
<ProjectReference Include="..\SharpLearning.InputOutput\SharpLearning.InputOutput.csproj" />
1515
</ItemGroup>
1616

17+
<ItemGroup>
18+
<PackageReference Include="Nerdbank.GitVersioning" Version="3.6.139">
19+
<PrivateAssets>all</PrivateAssets>
20+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
21+
</PackageReference>
22+
</ItemGroup>
23+
1724
</Project>

src/SharpLearning.XGBoost/SharpLearning.XGBoost.csproj

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,19 @@
99
<NoWarn>$(NoWarn);NU1701;MSB3270</NoWarn>
1010
</PropertyGroup>
1111

12-
<ItemGroup>
13-
<PackageReference Include="PicNet.XGBoost" Version="0.2.1" />
14-
</ItemGroup>
15-
1612
<ItemGroup>
1713
<ProjectReference Include="..\SharpLearning.Common.Interfaces\SharpLearning.Common.Interfaces.csproj" />
1814
<ProjectReference Include="..\SharpLearning.Containers\SharpLearning.Containers.csproj" />
1915
<ProjectReference Include="..\SharpLearning.GradientBoost\SharpLearning.GradientBoost.csproj" />
2016
<ProjectReference Include="..\SharpLearning.InputOutput\SharpLearning.InputOutput.csproj" />
2117
</ItemGroup>
2218

19+
<ItemGroup>
20+
<PackageReference Include="Nerdbank.GitVersioning" Version="3.6.139">
21+
<PrivateAssets>all</PrivateAssets>
22+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
23+
</PackageReference>
24+
<PackageReference Include="PicNet.XGBoost" Version="0.2.1" />
25+
</ItemGroup>
26+
2327
</Project>

version.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/main/src/NerdBank.GitVersioning/version.schema.json",
3+
"version": "0.40",
4+
"publicReleaseRefSpec": [
5+
"^refs/heads/master",
6+
"^refs/heads/v\\d+(?:\\.\\d+)?$"
7+
],
8+
"cloudBuild": {
9+
"buildNumber": {
10+
"enabled": false
11+
}
12+
}
13+
}

0 commit comments

Comments
 (0)