diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index 3ebe4653..d8bbd89f 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -2,20 +2,23 @@ name: dotnet +permissions: read-all + on: push: branches: [ "master" ] pull_request: branches: [ "master" ] - # workflow_dispatch: - # inputs: - # version: - # description: 'Release version to tag and create' - # required: false + workflow_dispatch: + inputs: + version: + description: 'Release version to tag and create' + required: false env: DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1 DOTNET_NOLOGO: true + NuGetDirectory: ${{ github.workspace }}/nuget jobs: build: @@ -28,6 +31,8 @@ jobs: steps: - uses: actions/checkout@v3 + with: + fetch-depth: 0 # Important for Nerdbank.GitVersioning to calculate versions - name: Setup .NET uses: actions/setup-dotnet@v3 with: @@ -37,8 +42,93 @@ jobs: - name: Build run: dotnet build -c ${{ matrix.configuration }} --no-restore - name: Test - run: dotnet test -c ${{ matrix.configuration }} --no-build --verbosity normal - # - name: Upload coverage reports to Codecov - # uses: codecov/codecov-action@v3 - # with: - # flags: ${{ matrix.os }},${{ matrix.configuration }} + run: dotnet test -c ${{ matrix.configuration }} --no-build --verbosity normal --collect:"XPlat Code Coverage" + - name: Upload coverage reports to Codecov + uses: codecov/codecov-action@v3 + with: + flags: ${{ matrix.os }},${{ matrix.configuration }} + + format: + strategy: + matrix: + os: [ubuntu-latest] + + runs-on: ${{ matrix.os }} + + steps: + - uses: actions/checkout@v3 + - name: Setup .NET + uses: actions/setup-dotnet@v3 + with: + global-json-file: global.json + - name: Format verify no changes + run: dotnet format --verify-no-changes + + pack: + runs-on: windows-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 # Important for Nerdbank.GitVersioning to calculate versions + - name: Setup .NET + uses: actions/setup-dotnet@v3 + with: + global-json-file: global.json + - name: Pack solution + run: dotnet pack SharpLearning.sln -c Release --output ${{ env.NuGetDirectory }} + - name: Add local package source + run: dotnet nuget add source ${{ env.NuGetDirectory }} --name local + - name: Get version of dll + run: (Get-Item './build/SharpLearning.AdaBoost_AnyCPU_Release_netstandard2.0/SharpLearning.AdaBoost.dll').VersionInfo.ProductVersion # unified version, so use AdaBoost dll. + - uses: actions/upload-artifact@v4 + with: + name: nuget + if-no-files-found: error + retention-days: 7 + path: ${{ env.NuGetDirectory }}/*nupkg + + create-release-push: + needs: [ build, pack ] + runs-on: windows-latest + permissions: + contents: write + if: ${{ github.event.inputs.version != '' && github.actor == 'mdabros'}} + + steps: + - uses: actions/checkout@v3 + - name: Download nuget packages + uses: actions/download-artifact@v4 + with: + name: nuget + path: ${{ env.NuGetDirectory }} + - name: Create release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.ACTION_GITHUB_TOKEN }} + with: + tag_name: v${{ github.event.inputs.version }} + release_name: ${{ github.event.inputs.version }} + draft: true + - name: Create tag (for release) + run: | + git tag v${{ github.event.inputs.version }} + git push origin v${{ github.event.inputs.version }} + - name: Upload NuGet packages + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.ACTION_GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ${{ env.NuGetDirectory }}/*.nupkg + asset_name: ${{ env.NuGetDirectory }}/*.nupkg + asset_content_type: application/zip + - name: Setup .NET + uses: actions/setup-dotnet@v3 + with: + global-json-file: global.json + - name: Push NuGet packages + run: | + for package in ${{ env.NuGetDirectory }}/*.nupkg; do + dotnet nuget push "$package" --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate + done \ No newline at end of file diff --git a/SharpLearning.sln b/SharpLearning.sln index 99af6458..5f580ccb 100644 --- a/SharpLearning.sln +++ b/SharpLearning.sln @@ -71,6 +71,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "root", "root", "{D83436F7-2 global.json = global.json LICENSE = LICENSE README.md = README.md + version.json = version.json EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{2204FA16-973A-48CF-A9FD-94FA72424BA4}" diff --git a/src/Directory.Build.props b/src/Directory.Build.props index f143dc5d..8bdff634 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -1,9 +1,5 @@ - 0.31.0 - 0.31.10 - $(FileVersion) - $(InformationalVersion) false diff --git a/src/SharpLearning.AdaBoost/SharpLearning.AdaBoost.csproj b/src/SharpLearning.AdaBoost/SharpLearning.AdaBoost.csproj index be58d2fd..b2bae433 100644 --- a/src/SharpLearning.AdaBoost/SharpLearning.AdaBoost.csproj +++ b/src/SharpLearning.AdaBoost/SharpLearning.AdaBoost.csproj @@ -15,4 +15,11 @@ + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + diff --git a/src/SharpLearning.Common.Interfaces/SharpLearning.Common.Interfaces.csproj b/src/SharpLearning.Common.Interfaces/SharpLearning.Common.Interfaces.csproj index bf9b4a20..da16c075 100644 --- a/src/SharpLearning.Common.Interfaces/SharpLearning.Common.Interfaces.csproj +++ b/src/SharpLearning.Common.Interfaces/SharpLearning.Common.Interfaces.csproj @@ -10,4 +10,11 @@ + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + diff --git a/src/SharpLearning.Containers/SharpLearning.Containers.csproj b/src/SharpLearning.Containers/SharpLearning.Containers.csproj index 32cafeab..8e0cd49d 100644 --- a/src/SharpLearning.Containers/SharpLearning.Containers.csproj +++ b/src/SharpLearning.Containers/SharpLearning.Containers.csproj @@ -7,4 +7,11 @@ true + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + diff --git a/src/SharpLearning.CrossValidation/SharpLearning.CrossValidation.csproj b/src/SharpLearning.CrossValidation/SharpLearning.CrossValidation.csproj index f6276eed..ccf199d5 100644 --- a/src/SharpLearning.CrossValidation/SharpLearning.CrossValidation.csproj +++ b/src/SharpLearning.CrossValidation/SharpLearning.CrossValidation.csproj @@ -17,4 +17,11 @@ + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + diff --git a/src/SharpLearning.DecisionTrees/SharpLearning.DecisionTrees.csproj b/src/SharpLearning.DecisionTrees/SharpLearning.DecisionTrees.csproj index 54d64411..80dd2b3e 100644 --- a/src/SharpLearning.DecisionTrees/SharpLearning.DecisionTrees.csproj +++ b/src/SharpLearning.DecisionTrees/SharpLearning.DecisionTrees.csproj @@ -14,4 +14,11 @@ + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + diff --git a/src/SharpLearning.Ensemble/SharpLearning.Ensemble.csproj b/src/SharpLearning.Ensemble/SharpLearning.Ensemble.csproj index eee99815..42ead8a6 100644 --- a/src/SharpLearning.Ensemble/SharpLearning.Ensemble.csproj +++ b/src/SharpLearning.Ensemble/SharpLearning.Ensemble.csproj @@ -15,4 +15,11 @@ + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + diff --git a/src/SharpLearning.FeatureTransformations/SharpLearning.FeatureTransformations.csproj b/src/SharpLearning.FeatureTransformations/SharpLearning.FeatureTransformations.csproj index 314a7c97..92275742 100644 --- a/src/SharpLearning.FeatureTransformations/SharpLearning.FeatureTransformations.csproj +++ b/src/SharpLearning.FeatureTransformations/SharpLearning.FeatureTransformations.csproj @@ -12,4 +12,11 @@ + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + diff --git a/src/SharpLearning.GradientBoost/SharpLearning.GradientBoost.csproj b/src/SharpLearning.GradientBoost/SharpLearning.GradientBoost.csproj index f1d69a71..2e352ab3 100644 --- a/src/SharpLearning.GradientBoost/SharpLearning.GradientBoost.csproj +++ b/src/SharpLearning.GradientBoost/SharpLearning.GradientBoost.csproj @@ -14,4 +14,11 @@ + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + diff --git a/src/SharpLearning.InputOutput/SharpLearning.InputOutput.csproj b/src/SharpLearning.InputOutput/SharpLearning.InputOutput.csproj index dd96a0c9..02ba11d8 100644 --- a/src/SharpLearning.InputOutput/SharpLearning.InputOutput.csproj +++ b/src/SharpLearning.InputOutput/SharpLearning.InputOutput.csproj @@ -11,4 +11,11 @@ + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + diff --git a/src/SharpLearning.Metrics/SharpLearning.Metrics.csproj b/src/SharpLearning.Metrics/SharpLearning.Metrics.csproj index 90ce8d87..08f330b1 100644 --- a/src/SharpLearning.Metrics/SharpLearning.Metrics.csproj +++ b/src/SharpLearning.Metrics/SharpLearning.Metrics.csproj @@ -12,4 +12,11 @@ + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + diff --git a/src/SharpLearning.Neural/SharpLearning.Neural.csproj b/src/SharpLearning.Neural/SharpLearning.Neural.csproj index 3e97e6e4..ae8e455b 100644 --- a/src/SharpLearning.Neural/SharpLearning.Neural.csproj +++ b/src/SharpLearning.Neural/SharpLearning.Neural.csproj @@ -11,15 +11,19 @@ neural network convolutional deep learning machine-learning classification regression - - - - - + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + diff --git a/src/SharpLearning.Optimization.Test/GlobalizedBoundedNelderMeadOptimizerTest.cs b/src/SharpLearning.Optimization.Test/GlobalizedBoundedNelderMeadOptimizerTest.cs index 196ac78b..c2a7ecb4 100644 --- a/src/SharpLearning.Optimization.Test/GlobalizedBoundedNelderMeadOptimizerTest.cs +++ b/src/SharpLearning.Optimization.Test/GlobalizedBoundedNelderMeadOptimizerTest.cs @@ -28,9 +28,10 @@ public void GlobalizedBoundedNelderMeadOptimizer_OptimizeBest(int? maxDegreeOfPa Assert.AreEqual(expected: -0.99999960731425908, actual.Error, Delta); Assert.AreEqual(expected: 3, actual.ParameterSet.Length); - Assert.AreEqual(expected: -1.5711056814954487, actual.ParameterSet[0], Delta); - Assert.AreEqual(expected: -6.283490634742785, actual.ParameterSet[1], Delta); - Assert.AreEqual(expected: -2.9822323517533149E-07, actual.ParameterSet[2], Delta); + const double delta = 1e-3; + Assert.AreEqual(expected: -1.5711056814954487, actual.ParameterSet[0], delta); + Assert.AreEqual(expected: -6.283490634742785, actual.ParameterSet[1], delta); + Assert.AreEqual(expected: -2.9822323517533149E-07, actual.ParameterSet[2], delta); } [TestMethod] diff --git a/src/SharpLearning.Optimization/SharpLearning.Optimization.csproj b/src/SharpLearning.Optimization/SharpLearning.Optimization.csproj index f724de17..3d7697f0 100644 --- a/src/SharpLearning.Optimization/SharpLearning.Optimization.csproj +++ b/src/SharpLearning.Optimization/SharpLearning.Optimization.csproj @@ -7,14 +7,17 @@ optimization grid search random particle swarm nelder-mead bayesian-optimization machine-learning - - - - + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + diff --git a/src/SharpLearning.RandomForest/SharpLearning.RandomForest.csproj b/src/SharpLearning.RandomForest/SharpLearning.RandomForest.csproj index afe493c2..9e46dcef 100644 --- a/src/SharpLearning.RandomForest/SharpLearning.RandomForest.csproj +++ b/src/SharpLearning.RandomForest/SharpLearning.RandomForest.csproj @@ -14,4 +14,11 @@ + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + diff --git a/src/SharpLearning.XGBoost/SharpLearning.XGBoost.csproj b/src/SharpLearning.XGBoost/SharpLearning.XGBoost.csproj index c02a7980..56b52356 100644 --- a/src/SharpLearning.XGBoost/SharpLearning.XGBoost.csproj +++ b/src/SharpLearning.XGBoost/SharpLearning.XGBoost.csproj @@ -9,10 +9,6 @@ $(NoWarn);NU1701;MSB3270 - - - - @@ -20,4 +16,12 @@ + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + diff --git a/version.json b/version.json new file mode 100644 index 00000000..d9413139 --- /dev/null +++ b/version.json @@ -0,0 +1,13 @@ +{ + "$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/main/src/NerdBank.GitVersioning/version.schema.json", + "version": "0.40", + "publicReleaseRefSpec": [ + "^refs/heads/master", + "^refs/heads/v\\d+(?:\\.\\d+)?$" + ], + "cloudBuild": { + "buildNumber": { + "enabled": false + } + } +} \ No newline at end of file