From f0d79cc798b5a1b14cde7841346f85b8a48a6cd8 Mon Sep 17 00:00:00 2001 From: Christian Kadluba <10721825+ckadluba@users.noreply.github.com> Date: Mon, 9 Sep 2024 14:10:04 +0200 Subject: [PATCH 1/4] .NET Package validation Prepared package validation in Serilog.Sinks.MSSqlServer.csproj. Not activated yet because it must be disabled during a major version release because there is not yet a base release to compare with on nuget.org. --- src/Serilog.Sinks.MSSqlServer/Serilog.Sinks.MSSqlServer.csproj | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Serilog.Sinks.MSSqlServer/Serilog.Sinks.MSSqlServer.csproj b/src/Serilog.Sinks.MSSqlServer/Serilog.Sinks.MSSqlServer.csproj index f701964d..75035c1d 100644 --- a/src/Serilog.Sinks.MSSqlServer/Serilog.Sinks.MSSqlServer.csproj +++ b/src/Serilog.Sinks.MSSqlServer/Serilog.Sinks.MSSqlServer.csproj @@ -3,6 +3,8 @@ A Serilog sink that writes events to Microsoft SQL Server and Azure SQL 7.0.0 + false + 7.0.0 Michiel van Oudheusden;Christian Kadluba;Serilog Contributors netstandard2.0;net462;net472;net6.0 true From 52ac86a34d66d2f13c062e4502281dbee5d29dbb Mon Sep 17 00:00:00 2001 From: Christian Kadluba <10721825+ckadluba@users.noreply.github.com> Date: Mon, 9 Sep 2024 14:11:01 +0200 Subject: [PATCH 2/4] Developer documentation Added DEVELOPMENT.md. Yet it has only info about how to create a release of the sink. --- DEVELOPMENT.md | 23 +++++++++++++++++++++++ serilog-sinks-mssqlserver.sln | 1 + 2 files changed, 24 insertions(+) create mode 100644 DEVELOPMENT.md diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md new file mode 100644 index 00000000..2d1146b8 --- /dev/null +++ b/DEVELOPMENT.md @@ -0,0 +1,23 @@ +# Creating Releases + +## Creating a Pre-release (-dev suffix) + +Whenever the `dev` branch is updated (after merging a pull request), the `Release` action is triggered. This action builds a nuget package with a prerelease identifier of the format `-dev-nnnnn` appended to the version number. This package is automatically published on nuget.org. + +## Creating a latest Release + +### Normal Update (no major version change) {#normal-update} + +1. On the `dev` branch, update CHANGES.md and `VersionPrefix` in Serilog.Sinks.MSSqlServer.csproj. + +1. Create a PR to merge the `dev` branch into `main`. The `Release` action will be triggered. This action builds a nuget package and publishes it on nuget.org. Additionally a release is created in the GitHub repo. The release summary will be taken from the description of the PR, so best thing is to put something similar to the version summary in CHANGES.md in there. + +1. After the release is done, increase the patch version number in `VersionPrefix` in Serilog.Sinks.MSSqlServer.csproj on the `dev` branch. This ensures that the next dev release will have a higher version number than the latest release. + +### Major Release (major version change) + +1. On the `dev` branch, update CHANGES.md and increase the major version in `VersionPrefix` in Serilog.Sinks.MSSqlServer.csproj. Also set `EnablePackageValidation` to false because on an intial release of a new major version you don't have a baseline version yet on nuget.org to compare with. + +1. Create a PR to merge the `dev` branch into `main`. The `Release` action will be triggered. This works the same as described above under [Normal Update]({#normal-update). + +1. After the release is done make some changes in Serilog.Sinks.MSSqlServer.csproj on the `dev` branch. Set `EnablePackageValidation` back to true and `PackageValidationBaselineVersion` to the version of the new major release you just created (e.g. 7.0.0). Then also increase the patch version number in `VersionPrefix` (e.g. 7.0.1). diff --git a/serilog-sinks-mssqlserver.sln b/serilog-sinks-mssqlserver.sln index ef9178ee..224100e3 100644 --- a/serilog-sinks-mssqlserver.sln +++ b/serilog-sinks-mssqlserver.sln @@ -24,6 +24,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution .editorconfig = .editorconfig Build.ps1 = Build.ps1 CHANGES.md = CHANGES.md + DEVELOPMENT.md = DEVELOPMENT.md Directory.Build.props = Directory.Build.props Directory.Packages.props = Directory.Packages.props .github\ISSUE_TEMPLATE.md = .github\ISSUE_TEMPLATE.md From ae1c4a7fc1e70b127726d0a98197b4c03ac01953 Mon Sep 17 00:00:00 2001 From: Christian Kadluba <10721825+ckadluba@users.noreply.github.com> Date: Mon, 9 Sep 2024 14:36:53 +0200 Subject: [PATCH 3/4] Build and release action improvements * Let Build.ps1 and release.yml run on an ubuntu agent * Full automatic release: use last commit message (usually merge commit from PR) as release description --- .github/workflows/release.yml | 58 ++++++++++++++++++++++------------- Build.ps1 | 38 +++++++++++------------ 2 files changed, 56 insertions(+), 40 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4700cab4..49e7c824 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -2,40 +2,56 @@ name: Release on: push: - branches: [ dev, main ] + branches: + - main + - dev # Allows you to run this workflow manually from the Actions tab workflow_dispatch: jobs: build-and-release: - runs-on: windows-latest + runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Read version from csproj + id: extract_version + if: github.ref == 'refs/heads/main' + run: | + VERSION=$(grep '' src/Serilog.Sinks.MSSqlServer/Serilog.Sinks.MSSqlServer.csproj | sed 's/.*\(.*\)<\/VersionPrefix>.*/\1/') + echo "VERSION=$VERSION" >> $GITHUB_ENV + if git rev-parse "v$VERSION" >/dev/null 2>&1; then + echo "Tag v$VERSION already exists" + exit 1 + fi - name: Run build run: ./Build.ps1 -SkipTests + shell: pwsh - - name: Read version from csproj + - name: Get last commit message + id: last_commit + if: success() && github.ref == 'refs/heads/main' run: | - $selectResult = Select-String -Path ".\src\Serilog.Sinks.MSSqlServer\Serilog.Sinks.MSSqlServer.csproj" -Pattern '(.+)' - $versionMatch = $selectResult.Matches[0].Groups[1].Value - echo ("VERSION=" + $versionMatch) >> $env:GITHUB_ENV - echo "Found version $versionMatch" - - - name: Create GitHub release - if: ${{ github.ref_name == 'main' }} - uses: "marvinpinto/action-automatic-releases@latest" - with: - repo_token: "${{ secrets.GITHUB_TOKEN }}" - prerelease: false - automatic_release_tag: "v${{ env.VERSION }}" - title: "v${{ env.VERSION }}" - files: | - artifacts/*.nupkg - artifacts/*.snupkg + git log -1 --pretty=%B > last_commit_message.txt + + # Create GitHub release only on main branch (latest release) + - name: Create Release + if: github.ref == 'refs/heads/main' && success() + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + gh release create v${{ env.VERSION }} \ + --title "v${{ env.VERSION }}" \ + --notes "$(cat last_commit_message.txt)" \ + artifacts/*.nupkg artifacts/*.snupkg - name: Publish to nuget.org env: NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }} - run: nuget push artifacts\*.nupkg -Source 'https://api.nuget.org/v3/index.json' -ApiKey ${{ env.NUGET_API_KEY }} + run: | + nuget push artifacts/*.nupkg -Source https://api.nuget.org/v3/index.json -ApiKey ${{ secrets.NUGET_API_KEY }} + nuget push artifacts/*.snupkg -Source https://api.nuget.org/v3/index.json -ApiKey ${{ secrets.NUGET_API_KEY }} diff --git a/Build.ps1 b/Build.ps1 index 99d8c9a5..9beacfc8 100644 --- a/Build.ps1 +++ b/Build.ps1 @@ -7,55 +7,55 @@ param ( echo "build: Build started" -Push-Location $PSScriptRoot +Push-Location "$PSScriptRoot" -if(Test-Path .\artifacts) { - echo "build: Cleaning .\artifacts" - Remove-Item .\artifacts -Force -Recurse +if (Test-Path .\artifacts) { + echo "build: Cleaning .\artifacts" + Remove-Item .\artifacts -Force -Recurse } & dotnet restore --no-cache -$branch = @{ $true = $env:GITHUB_REF_NAME; $false = $(git symbolic-ref --short -q HEAD) }[$env:GITHUB_REF_NAME -ne $NULL]; -$revision = @{ $true = "{0:00000}" -f [convert]::ToInt32("0" + $env:GITHUB_RUN_NUMBER, 10); $false = "local" }[$env:GITHUB_RUN_NUMBER -ne $NULL]; -$suffix = @{ $true = ""; $false = "$($branch.Substring(0, [math]::Min(10,$branch.Length)))-$revision"}[$branch -ne "dev" -and $revision -ne "local"] +$branch = @{ $true = $env:GITHUB_REF_NAME; $false = $(git symbolic-ref --short -q HEAD) }[$env:GITHUB_REF_NAME -ne $NULL] +$revision = @{ $true = "{0:00000}" -f [convert]::ToInt32("0" + $env:GITHUB_RUN_NUMBER, 10); $false = "local" }[$env:GITHUB_RUN_NUMBER -ne $NULL] +$suffix = @{ $true = ""; $false = "$($branch.Substring(0, [math]::Min(10, $branch.Length)))-$revision" }[$branch -ne "dev" -and $revision -ne "local"] echo "build: Version suffix is $suffix" -foreach ($src in ls src/*) { - Push-Location $src +foreach ($src in Get-ChildItem "$PSScriptRoot/src" -Directory) { + Push-Location $src.FullName - echo "build: Packaging project in $src" + echo "build: Packaging project in $($src.FullName)" if ($suffix) { & dotnet pack -c Release -o ..\..\artifacts --version-suffix=$suffix } else { & dotnet pack -c Release -o ..\..\artifacts } - if($LASTEXITCODE -ne 0) { exit 1 } + if ($LASTEXITCODE -ne 0) { exit 1 } Pop-Location } if ($SkipTests -eq $false) { - foreach ($test in ls test/*.PerformanceTests) { - Push-Location $test + foreach ($test in Get-ChildItem "$PSScriptRoot/test" -Filter "*.PerformanceTests" -Directory) { + Push-Location $test.FullName - echo "build: Building performance test project in $test" + echo "build: Building performance test project in $($test.FullName)" & dotnet build -c Release - if($LASTEXITCODE -ne 0) { exit 2 } + if ($LASTEXITCODE -ne 0) { exit 2 } Pop-Location } - foreach ($test in ls test/*.Tests) { - Push-Location $test + foreach ($test in Get-ChildItem "$PSScriptRoot/test" -Filter "*.Tests" -Directory) { + Push-Location $test.FullName - echo "build: Testing project in $test" + echo "build: Testing project in $($test.FullName)" & dotnet test -c Release --collect "XPlat Code Coverage" - if($LASTEXITCODE -ne 0) { exit 3 } + if ($LASTEXITCODE -ne 0) { exit 3 } Pop-Location } From 69d953860dc69c32acfed3d8cb00232fd83e8bc3 Mon Sep 17 00:00:00 2001 From: Christian Kadluba <10721825+ckadluba@users.noreply.github.com> Date: Mon, 9 Sep 2024 14:40:02 +0200 Subject: [PATCH 4/4] Updated CHANGES.md --- CHANGES.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 5a495f46..74621757 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,8 @@ # 7.0.0 * Fixed issue #543: Update to Serilog v4, remove reference to Serilog.Sinks.PeriodicBatching (thanks to @cancakar35) +* Full automatic release and run on ubuntu-latest agent +* Added developer documentation +* Enabled .NET package validation # 6.7.1 * Fixed issue #552 by downgrading SqlClient dependency to 5.1.6 which is LTS and fixed the vulnerabilities referenced in issue #544