Skip to content

Commit a03b536

Browse files
Add pre-release workflow and generate changelog in release build
1 parent dca8447 commit a03b536

File tree

5 files changed

+112
-24
lines changed

5 files changed

+112
-24
lines changed

.github/workflows/dotnet.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,6 @@ jobs:
1313

1414
steps:
1515
- uses: actions/checkout@v2
16-
- name: Setup .NET
17-
uses: actions/setup-dotnet@v1
18-
with:
19-
dotnet-version: |
20-
3.1.x
21-
6.0.x
2216
- name: Restore dependencies
2317
run: dotnet restore
2418
- name: Build

.github/workflows/pre_release.yaml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: pre-release
2+
3+
on: workflow_dispatch
4+
5+
jobs:
6+
build:
7+
8+
runs-on: windows-latest
9+
10+
steps:
11+
- uses: actions/checkout@v2
12+
- name: Get the version
13+
id: get_version
14+
uses: mavrosxristoforos/[email protected]
15+
with:
16+
xml-file: './Directory.Build.props'
17+
xpath: '//Version'
18+
- name: Create short version
19+
id: shortversion
20+
run: |
21+
$version = "${{ steps.get_version.outputs.info }}".Substring(0, "${{ steps.get_version.outputs.info }}".LastIndexOf("."))
22+
Write-Host "::set-output name=shortversion::$version"
23+
shell: pwsh
24+
- uses: actions/checkout@v2
25+
- name: Restore dependencies
26+
run: dotnet restore
27+
- name: Build
28+
run: dotnet build --no-restore -c Release .\Serilog.Enrichers.Sensitive.sln
29+
- name: Test
30+
run: dotnet test --no-build --verbosity normal -c Release
31+
- name: Create NuGet package for Serilog.Enrichers.Sensitive
32+
run: dotnet pack ./src/Serilog.Enrichers.Sensitive/Serilog.Enrichers.Sensitive.csproj -c Release --no-build --no-restore -o ./packaging
33+
- name: Get changelog
34+
id: get_changelog
35+
run: |
36+
./get-changelog.ps1 -currentVersion "${{ steps.get_version.outputs.info }}"
37+
shell: pwsh
38+
- name: Create Release
39+
id: create_release
40+
uses: actions/create-release@v1
41+
env:
42+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
43+
with:
44+
tag_name: ${{ steps.get_version.outputs.info }}
45+
release_name: ${{ steps.get_version.outputs.info }}
46+
draft: false
47+
prerelease: true
48+
body_path: ./version-changelog.md
49+
- name: Upload enricher NuGet package
50+
id: upload-nuget-enricher
51+
uses: actions/upload-release-asset@v1
52+
env:
53+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
54+
with:
55+
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
56+
asset_path: ./packaging/Serilog.Enrichers.Sensitive.${{ steps.shortversion.outputs.shortversion }}.nupkg
57+
asset_name: Serilog.Enrichers.Sensitive.${{ steps.shortversion.outputs.shortversion }}.nupkg
58+
asset_content_type: application/octet-stream
59+
- name: Publish enricher package to public NuGet repository
60+
run: dotnet nuget push -k ${{ secrets.NUGET_TOKEN }} -s https://api.nuget.org/v3/index.json ./packaging/Serilog.Enrichers.Sensitive.${{ steps.shortversion.outputs.shortversion }}.nupkg --skip-duplicate --no-symbols

.github/workflows/release.yml

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,44 +11,53 @@ jobs:
1111
runs-on: windows-latest
1212

1313
steps:
14+
- uses: actions/checkout@v2
1415
- name: Get the version
1516
id: get_version
16-
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\/releases\//}
17-
shell: bash
18-
- uses: actions/checkout@v2
19-
- name: Setup .NET
20-
uses: actions/setup-dotnet@v1
17+
uses: mavrosxristoforos/[email protected]
2118
with:
22-
dotnet-version: |
23-
3.1.x
24-
6.0.x
19+
xml-file: './Directory.Build.props'
20+
xpath: '//Version'
21+
- name: Create short version
22+
id: shortversion
23+
run: |
24+
$version = "${{ steps.get_version.outputs.info }}".Substring(0, "${{ steps.get_version.outputs.info }}".LastIndexOf("."))
25+
Write-Host "::set-output name=shortversion::$version"
26+
shell: pwsh
27+
- uses: actions/checkout@v2
2528
- name: Restore dependencies
2629
run: dotnet restore
2730
- name: Build
2831
run: dotnet build --no-restore -c Release .\Serilog.Enrichers.Sensitive.sln
2932
- name: Test
3033
run: dotnet test --no-build --verbosity normal -c Release
31-
- name: Create NuGet package
32-
run: dotnet pack ./src/Serilog.Enrichers.Sensitive/Serilog.Enrichers.Sensitive.csproj -c Release --no-build --no-restore
34+
- name: Create NuGet package for Serilog.Enrichers.Sensitive
35+
run: dotnet pack ./src/Serilog.Enrichers.Sensitive/Serilog.Enrichers.Sensitive.csproj -c Release --no-build --no-restore -o ./packaging
36+
- name: Get changelog
37+
id: get_changelog
38+
run: |
39+
./get-changelog.ps1 -currentVersion "${{ steps.get_version.outputs.info }}"
40+
shell: pwsh
3341
- name: Create Release
3442
id: create_release
3543
uses: actions/create-release@v1
3644
env:
3745
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3846
with:
39-
tag_name: ${{ steps.get_version.outputs.VERSION }}
40-
release_name: ${{ steps.get_version.outputs.VERSION }}
47+
tag_name: ${{ steps.get_version.outputs.info }}
48+
release_name: ${{ steps.get_version.outputs.info }}
4149
draft: false
4250
prerelease: false
43-
- name: Upload NuGet package
44-
id: upload-release-asset
51+
body_path: ./version-changelog.md
52+
- name: Upload enricher NuGet package
53+
id: upload-nuget-enricher
4554
uses: actions/upload-release-asset@v1
4655
env:
4756
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4857
with:
4958
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
50-
asset_path: ./packaging/Serilog.Enrichers.Sensitive.${{ steps.get_version.outputs.VERSION }}.nupkg
51-
asset_name: Serilog.Enrichers.Sensitive.${{ steps.get_version.outputs.VERSION }}.nupkg
59+
asset_path: ./packaging/Serilog.Enrichers.Sensitive.${{ steps.shortversion.outputs.shortversion }}.nupkg
60+
asset_name: Serilog.Enrichers.Sensitive.${{ steps.shortversion.outputs.shortversion }}.nupkg
5261
asset_content_type: application/octet-stream
53-
- name: Publish package to public NuGet repository
54-
run: dotnet nuget push -k ${{ secrets.NUGET_TOKEN }} ./packaging/Serilog.Enrichers.Sensitive.${{ steps.get_version.outputs.VERSION }}.nupkg --skip-duplicate --no-symbols true
62+
- name: Publish enricher package to public NuGet repository
63+
run: dotnet nuget push -k ${{ secrets.NUGET_TOKEN }} -s https://api.nuget.org/v3/index.json ./packaging/Serilog.Enrichers.Sensitive.${{ steps.shortversion.outputs.shortversion }}.nupkg --skip-duplicate --no-symbols

CHANGELOG renamed to Changelog.md

File renamed without changes.

get-changelog.ps1

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
param([string]$currentVersion = $(throw "currentVersion is required"))
2+
3+
$lines = get-content Changelog.md
4+
5+
$started = $false
6+
$output = @()
7+
8+
for($index = 0; $index -lt $lines.Length; $index++)
9+
{
10+
$line = $lines[$index].Trim()
11+
if($line -eq "## $currentVersion")
12+
{
13+
$started = $true
14+
}
15+
elseif($started -and $line.StartsWith("## "))
16+
{
17+
break
18+
}
19+
elseif($started)
20+
{
21+
$output += $line
22+
}
23+
}
24+
25+
$output > version-changelog.md

0 commit comments

Comments
 (0)