Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
109 changes: 96 additions & 13 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,107 @@ jobs:
- name: Run build
run: ./Build.ps1 -SkipTests

- name: Read version from csproj
# - name: Read version from csproj
# run: |
# $selectResult = Select-String -Path ".\src\Serilog.Sinks.MSSqlServer\Serilog.Sinks.MSSqlServer.csproj" -Pattern '<VersionPrefix>(.+)</VersionPrefix>'
# $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

- name: Extract version from .csproj
id: extract_version
run: |
version=$(grep '<Version>' src/Serilog.Sinks.MSSqlServer/Serilog.Sinks.MSSqlServer.csproj | sed -E 's/.*<Version>([^<]+)<\/Version>.*/\1/')
echo "VERSION=$version" >> $GITHUB_ENV
echo "Extracted version: $version"

- name: Get the last commit message
id: last_commit
if: ${{ github.ref_name == 'main' }}
run: echo "LAST_COMMIT=$(git log -1 --pretty=%B)" >> $GITHUB_ENV

- name: Get the commits since the last release
id: commits_since_last_release
if: ${{ github.ref_name == 'main' }}
run: |
last_tag=$(git describe --tags --abbrev=0)
commits=$(git log $last_tag..HEAD --pretty=format:"- %s")
echo "COMMITS_SINCE_LAST_RELEASE=$commits" >> $GITHUB_ENV

- name: Get closed issues since last release
id: closed_issues
if: ${{ github.ref_name == 'main' }}
run: |
last_tag=$(git describe --tags --abbrev=0)
issues=$(gh issue list --state closed --search "merged:>$last_tag" --json number,title --jq '.[] | "- #" + (.number|tostring) + " " + .title')
echo "CLOSED_ISSUES=$issues" >> $GITHUB_ENV

- name: Get contributors since last release
id: contributors
if: ${{ github.ref_name == 'main' }}
run: |
$selectResult = Select-String -Path ".\src\Serilog.Sinks.MSSqlServer\Serilog.Sinks.MSSqlServer.csproj" -Pattern '<VersionPrefix>(.+)</VersionPrefix>'
$versionMatch = $selectResult.Matches[0].Groups[1].Value
echo ("VERSION=" + $versionMatch) >> $env:GITHUB_ENV
echo "Found version $versionMatch"
contributors=$(git log --format='%aN <%aE>' $last_tag..HEAD | sort | uniq | awk -F'<|>' '{print $1 " (" $2 ")"}' | sort | uniq | sed 's/^/- /')
echo "CONTRIBUTORS=$contributors" >> $GITHUB_ENV

- name: Create GitHub release
- name: Create Git Tag
id: create_tag
if: ${{ github.ref_name == 'main' }}
uses: "marvinpinto/action-automatic-releases@latest"
run: |
git config user.name "GitHub Actions"
git config user.email "[email protected]"
git tag -a "v${{ env.VERSION }}" -m "Release version ${{ env.VERSION }}"
git push origin "v${{ env.VERSION }}"

- name: Create Release
id: create_release
if: ${{ github.ref_name == 'main' }}
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
tag_name: "v${{ env.VERSION }}" # Der Tag-Name, der das Release auslöst
release_name: "v${{ env.VERSION }}" # Der Name des Releases
body: |
## Details
${{ env.LAST_COMMIT }}

## Commits
${{ env.COMMITS_SINCE_LAST_RELEASE }}

## Contributors
${{ env.CONTRIBUTORS }}
draft: false
prerelease: false
automatic_release_tag: "v${{ env.VERSION }}"
title: "v${{ env.VERSION }}"
files: |
artifacts/*.nupkg
artifacts/*.snupkg

- name: Upload NuGet packages to Release
if: ${{ github.ref_name == 'main' }}
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: artifacts/*.nupkg
asset_name: serilog.sinks.mssqlserver.${{ env.VERSION }}.nupkg
asset_content_type: application/zip

- name: Upload NuGet symbol packages to Release
if: ${{ github.ref_name == 'main' }}
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: artifacts/*.snupkg
asset_name: serilog.sinks.mssqlserver.${{ env.VERSION }}.snupkg
asset_content_type: application/zip

- name: Publish to nuget.org
env:
Expand Down
15 changes: 15 additions & 0 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Creating Releases

## Creating a dev Release

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

1. On the `dev` branch, update CHANGES.md and `VersionPrefix` and `PackageValidationBaselineVersion` (if applicable, e.g. major version was increased) in Serilog.Sinks.MSSqlServer.csproj.

1. 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.

1. Edit the GitHub release and copy the release notes from CHANGES.md.

1. After the release is done, increase the version number in Serilog.Sinks.MSSqlServer.csproj. This ensures that the next dev release will have a higher version number than the latest release.
1 change: 1 addition & 0 deletions serilog-sinks-mssqlserver.sln
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">

<!--<Sdk Name="Microsoft.DotNet.PackageValidation" Version="1.0.0-preview.7.21379.12" />-->

<PropertyGroup>
<Description>A Serilog sink that writes events to Microsoft SQL Server and Azure SQL</Description>
<VersionPrefix>7.0.0</VersionPrefix>
<EnablePackageValidation>true</EnablePackageValidation>
<PackageValidationBaselineVersion>7.0.0</PackageValidationBaselineVersion>
<Authors>Michiel van Oudheusden;Christian Kadluba;Serilog Contributors</Authors>
<TargetFrameworks>netstandard2.0;net462;net472;net6.0</TargetFrameworks>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
Expand Down
Loading