Skip to content

Commit 8860554

Browse files
committed
ci-fix: embed latest release notes in nugets, push version numbers
1 parent 1e85484 commit 8860554

8 files changed

Lines changed: 88 additions & 55 deletions

File tree

.github/workflows/docs-deploy.yml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@ on:
1515

1616
workflow_dispatch:
1717

18+
env:
19+
VSTEST_CONNECTION_TIMEOUT: 180
20+
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
21+
DOTNET_NOLOGO: true
22+
DOTNET_SYSTEM_CONSOLE_ALLOW_ANSI_COLOR_REDIRECTION: 1
23+
TERM: xterm
24+
1825
jobs:
1926
deploy:
2027
name: 📃 Deploy new version bunit.dev
@@ -55,10 +62,11 @@ jobs:
5562

5663
- name: 🛠️ Update tokens in project files
5764
uses: cschleiden/replace-tokens@v1
58-
env:
59-
RELEASE-VERSION: ${{ steps.changelog_reader.outputs.version }}
6065
with:
61-
files: '["docs/site/docfx.json", "docs/site/*.md", "docs/**/*.md", "docs/**/*.tmpl.partial", "*.csproj", "**/*.csproj"]'
66+
files: '["docs/site/*.md", "docs/**/*.md", "docs/**/*.tmpl.partial", "*.csproj", "**/*.csproj", "src/Directory.Build.props"]'
67+
env:
68+
RELEASE_VERSION: ${{ steps.changelog_reader.outputs.version }}
69+
RELEASE_NOTES: ${{ steps.changelog_reader.outputs.changes }}
6270

6371
- name: ⚙️ Setup dotnet versions
6472
uses: actions/setup-dotnet@v3

.github/workflows/prepare-release.yml

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ on:
88
description: 'The version increment. Allowed values are "major" and "minor".'
99
required: true
1010
default: 'minor'
11-
12-
jobs:
11+
12+
jobs:
1313
prepare-release:
1414
name: 🚚 Prepare new release
1515
runs-on: ubuntu-latest
1616
if: github.ref == 'refs/heads/main' && contains(fromJson('["major","minor"]'), github.event.inputs.versionIncrement)
17-
steps:
17+
steps:
1818
- name: 🛒 Checkout repository
1919
uses: actions/checkout@v4
2020
with:
@@ -27,39 +27,40 @@ jobs:
2727
with:
2828
version: Unreleased
2929
path: ./CHANGELOG.md
30-
30+
3131
- name: ☑ Check that release contains changes
3232
if: steps.changelog_reader.outputs.changes == ''
3333
run: |
3434
echo "::error file=CHANGELOG.md::The unreleased section in the changelog is empty. Nothing to release."
3535
exit 1
36+
3637
- name: ⚙️ Import GPG key
3738
id: import_gpg
3839
uses: crazy-max/ghaction-import-gpg@v6
3940
with:
4041
gpg_private_key: ${{ secrets.BUNIT_BOT_GPG_PRIVATE_KEY }}
4142
passphrase: ${{ secrets.BUNIT_BOT_GPG_KEY_PASSPHRASE }}
42-
43+
4344
- name: ⚙️ Setup CI GIT
4445
run: |
4546
git config user.name "${{ steps.import_gpg.outputs.name }}"
4647
git config user.email ${{ steps.import_gpg.outputs.email }}
4748
git config --global user.signingkey ${{ steps.import_gpg.outputs.keyid }}
48-
git config --global commit.gpgsign true
49-
49+
git config --global commit.gpgsign true
50+
5051
- name: ⚙️ Setup GIT versioning
5152
uses: dotnet/nbgv@v0.4.1
5253
with:
5354
setAllVars: true
54-
55+
5556
- name: 🛠️ Increment version.json on main + create release branch
5657
id: versions
5758
run: |
58-
nbgv prepare-release --versionIncrement ${{ github.event.inputs.versionIncrement }}
59+
nbgv prepare-release --versionIncrement ${{ github.event.inputs.versionIncrement }}
5960
echo "MAIN_VERSION_COMMIT_MESSAGE=$(git log --format=%B -n 1 --skip 1)" >> $GITHUB_OUTPUT
6061
git checkout release/v$NBGV_MajorMinorVersion
6162
echo "RELEASE_VERSION_COMMIT_MESSAGE=$(git log --format=%B -n 1)" >> $GITHUB_OUTPUT
62-
63+
6364
# Workaround since nbgv prepare-release does not sign commits.
6465
# This undo's the commits, keeps the version changes, and commits again with signing
6566
# with the saved commit messages from previous step.
@@ -69,16 +70,16 @@ jobs:
6970
git checkout release/v$NBGV_MajorMinorVersion
7071
git reset --soft HEAD~1
7172
git commit -S -m "${{ steps.versions.outputs.RELEASE_VERSION_COMMIT_MESSAGE }}"
72-
73+
7374
git checkout main
7475
git reset --hard HEAD~1
7576
git reset --soft HEAD~1
7677
git commit -S -m "${{ steps.versions.outputs.MAIN_VERSION_COMMIT_MESSAGE }}"
7778
git merge -S -X ours release/v$NBGV_MajorMinorVersion
78-
79+
7980
- name: ⏩ Push version.json updates to main
8081
run: git push origin main
81-
82+
8283
- name: ⏩ Push release branch to origin
8384
run: git push origin release/v$NBGV_MajorMinorVersion
8485

@@ -92,7 +93,7 @@ jobs:
9293
title: Release of new ${{ github.event.inputs.versionIncrement }} version v${{ env.NBGV_MajorMinorVersion }}
9394
body: |
9495
This PR was created in response to a manual trigger of the [prepare-release workflow](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}).
95-
96+
9697
Merging this PR will create a GitHub Release and push new packages to NuGet.
97-
98+
9899
**NOTE:** Only small fixes should be added to this PR at this point. If you need to make minor or major changes, close the PR and make those changes to ${{ github.ref }} instead, and run the prepare-release workflow again once you are done.

.github/workflows/release-preview.yml

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ on:
77
types: [completed]
88
branches: [main, v2]
99

10+
env:
11+
VSTEST_CONNECTION_TIMEOUT: 180
12+
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
13+
DOTNET_NOLOGO: true
14+
DOTNET_SYSTEM_CONSOLE_ALLOW_ANSI_COLOR_REDIRECTION: 1
15+
TERM: xterm
16+
1017
jobs:
1118
release-preview:
1219
if: github.event_name == 'workflow_dispatch' || (github.ref == 'refs/heads/main' && ${{ github.event.workflow_run.conclusion == 'success' }}) || (github.ref == 'refs/heads/v2' && ${{ github.event.workflow_run.conclusion == 'success' }})
@@ -31,15 +38,20 @@ jobs:
3138
7.0.x
3239
8.0.x
3340
34-
- name: 🎨 Setup color
35-
run: |
36-
echo "DOTNET_SYSTEM_CONSOLE_ALLOW_ANSI_COLOR_REDIRECTION=1" >> $GITHUB_ENV
37-
echo "TERM=xterm" >> $GITHUB_ENV
41+
- name: 🛠️ Get Changelog Entry
42+
id: changelog_reader
43+
uses: mindsers/changelog-reader-action@v2
44+
with:
45+
version: Unreleased
46+
path: ./CHANGELOG.md
3847

3948
- name: 🛠️ Update tokens in project files
4049
uses: cschleiden/replace-tokens@v1
4150
with:
42-
files: '["*.csproj", "**/*.csproj"]'
51+
files: '["docs/site/*.md", "docs/**/*.md", "docs/**/*.tmpl.partial", "*.csproj", "**/*.csproj", "src/Directory.Build.props"]'
52+
env:
53+
RELEASE_VERSION: ${{ env.NBGV_NuGetPackageVersion }}
54+
RELEASE_NOTES: ${{ steps.changelog_reader.outputs.changes }}
4355

4456
- name: 🛠️ Packing library in release mode
4557
run: |

.github/workflows/release.yml

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@ on:
1212

1313
workflow_dispatch:
1414

15+
env:
16+
VSTEST_CONNECTION_TIMEOUT: 180
17+
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
18+
DOTNET_NOLOGO: true
19+
DOTNET_SYSTEM_CONSOLE_ALLOW_ANSI_COLOR_REDIRECTION: 1
20+
TERM: xterm
21+
1522
jobs:
1623
release:
1724
name: 🎁 Publish new release
@@ -27,19 +34,6 @@ jobs:
2734
fetch-depth: 0
2835
token: ${{ secrets.BUNIT_BOT_TOKEN }}
2936

30-
- name: 🛠️ Get Changelog Entry
31-
id: changelog_reader
32-
uses: mindsers/changelog-reader-action@v2
33-
with:
34-
version: Unreleased
35-
path: ./CHANGELOG.md
36-
37-
- name: ☑ Check that release contains changes
38-
if: steps.changelog_reader.outputs.changes == ''
39-
run: |
40-
echo "::error file=CHANGELOG.md::The unreleased section in the changelog is empty. Nothing to release."
41-
exit 1
42-
4337
- name: ⚙️ Import GPG key
4438
id: import_gpg
4539
uses: crazy-max/ghaction-import-gpg@v6
@@ -86,10 +80,20 @@ jobs:
8680
git commit -S -m "Updated CHANGELOG.md for ${{ env.NBGV_SimpleVersion }} release"
8781
echo "RELEASE_COMMIT_HASH=$(git rev-parse stable)" >> $GITHUB_ENV
8882
83+
- name: 🛠️ Get Changelog Entry
84+
id: changelog_reader
85+
uses: mindsers/changelog-reader-action@v2
86+
with:
87+
version: ${{ env.NBGV_SemVer2 }}
88+
path: ./CHANGELOG.md
89+
8990
- name: 🛠️ Update tokens in project files
9091
uses: cschleiden/replace-tokens@v1
9192
with:
92-
files: '["*.csproj", "**/*.csproj"]'
93+
files: '["docs/site/*.md", "docs/**/*.md", "docs/**/*.tmpl.partial", "*.csproj", "**/*.csproj", "src/Directory.Build.props"]'
94+
env:
95+
RELEASE_VERSION: ${{ env.NBGV_NuGetPackageVersion }}
96+
RELEASE_NOTES: ${{ steps.changelog_reader.outputs.changes }}
9397

9498
- name: 🛠️ Packing library in release mode
9599
run: |

.github/workflows/verification.yml

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,20 @@ jobs:
5555
with:
5656
setAllVars: true
5757

58-
- name: 🍥 Replace tokens in files
58+
- name: 🛠️ Get Changelog Entry
59+
id: changelog_reader
60+
uses: mindsers/changelog-reader-action@v2
61+
with:
62+
version: Unreleased
63+
path: ./CHANGELOG.md
64+
65+
- name: 🛠️ Update tokens in project files
5966
uses: cschleiden/replace-tokens@v1
6067
with:
61-
files: '["docs/site/*.md", "docs/**/*.md", "docs/**/*.tmpl.partial", "*.csproj", "**/*.csproj"]'
68+
files: '["docs/site/*.md", "docs/**/*.md", "docs/**/*.tmpl.partial", "*.csproj", "**/*.csproj", "src/Directory.Build.props"]'
69+
env:
70+
RELEASE_VERSION: ${{ env.NBGV_NuGetPackageVersion }}
71+
RELEASE_NOTES: ${{ steps.changelog_reader.outputs.changes }}
6272

6373
# Create the NuGet package in the folder from the environment variable NuGetDirectory
6474
- run: |
@@ -137,6 +147,10 @@ jobs:
137147
runs-on: ubuntu-latest
138148
needs: [ create-nuget ]
139149
steps:
150+
- uses: actions/checkout@v3
151+
with:
152+
fetch-depth: 0 # Get all history to allow automatic versioning using MinVer
153+
140154
- name: Setup .NET
141155
uses: actions/setup-dotnet@v3
142156

@@ -152,32 +166,31 @@ jobs:
152166

153167
- name: ✳ Install bUnit template
154168
run: |
155-
dotnet new --install bunit.template::${NBGV_NuGetPackageVersion} --nuget-source ${{ env.NUGET_DIRECTORY }}
169+
dotnet new install bunit.template::${NBGV_NuGetPackageVersion} --nuget-source ${{ env.NUGET_DIRECTORY }}
156170
157171
- name: ✔ Verify xUnit template
158172
run: |
159173
dotnet new bunit --no-restore -o ${{ github.workspace }}/TemplateTestXunit
160174
echo '<?xml version="1.0" encoding="utf-8"?><Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"></Project>' >> ${{ github.workspace }}/TemplateTestXunit/Directory.Build.props
161-
dotnet restore ${{ github.workspace }}/TemplateTestXunit --source https://api.nuget.org/v3/index.json --source ${{ github.workspace }}/packages
175+
dotnet restore ${{ github.workspace }}/TemplateTestXunit --source https://api.nuget.org/v3/index.json --source ${{ env.NUGET_DIRECTORY }}
162176
dotnet test ${{ github.workspace }}/TemplateTestXunit
163177
164178
- name: ✔ Verify NUnit template
165179
run: |
166180
dotnet new bunit --framework nunit --no-restore -o ${{ github.workspace }}/TemplateTestNunit
167181
echo '<?xml version="1.0" encoding="utf-8"?><Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"></Project>' >> ${{ github.workspace }}/TemplateTestNunit/Directory.Build.props
168-
dotnet restore ${{ github.workspace }}/TemplateTestNunit --source https://api.nuget.org/v3/index.json --source ${{ github.workspace }}/packages
182+
dotnet restore ${{ github.workspace }}/TemplateTestNunit --source https://api.nuget.org/v3/index.json --source ${{ env.NUGET_DIRECTORY }}
169183
dotnet test ${{ github.workspace }}/TemplateTestNunit
170184
171185
- name: ✔ Verify MSTest template
172186
run: |
173187
dotnet new bunit --framework mstest --no-restore -o ${{ github.workspace }}/TemplateTestMstest
174188
echo '<?xml version="1.0" encoding="utf-8"?><Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"></Project>' >> ${{ github.workspace }}/TemplateTestMstest/Directory.Build.props
175-
dotnet restore ${{ github.workspace }}/TemplateTestMstest --source https://api.nuget.org/v3/index.json --source ${{ github.workspace }}/packages
189+
dotnet restore ${{ github.workspace }}/TemplateTestMstest --source https://api.nuget.org/v3/index.json --source ${{ env.NUGET_DIRECTORY }}
176190
dotnet test ${{ github.workspace }}/TemplateTestMstest
177191
178192
validate-docs:
179193
runs-on: ubuntu-latest
180-
181194
steps:
182195
- name: 🛒 Checkout repository
183196
uses: actions/checkout@v4
@@ -208,7 +221,7 @@ jobs:
208221
run: dotnet build
209222

210223
- name: 🧪 Run sample unit tests
211-
run: dotnet test -c release docs/samples/samples.sln
224+
run: dotnet test docs/samples/samples.sln
212225

213226
- name: 📄 Build docs
214227
working-directory: ./docs/site

docs/site/docs/getting-started/create-test-project.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ The result should be a test project with a `.csproj` that looks like this (non b
171171
</PropertyGroup>
172172

173173
<ItemGroup>
174-
<PackageReference Include="bunit" Version="#{RELEASE-VERSION}#" />
174+
<PackageReference Include="bunit" Version="#{RELEASE_VERSION}#" />
175175
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
176176
<PackageReference Include="xunit" Version="2.4.2" />
177177
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
@@ -200,7 +200,7 @@ The result should be a test project with a `.csproj` that looks like this (non b
200200
</PropertyGroup>
201201

202202
<ItemGroup>
203-
<PackageReference Include="bunit" Version="#{RELEASE-VERSION}#" />
203+
<PackageReference Include="bunit" Version="#{RELEASE_VERSION}#" />
204204
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
205205
<PackageReference Include="NUnit" Version="3.13.3" />
206206
<PackageReference Include="NUnit3TestAdapter" Version="4.4.2" />
@@ -226,7 +226,7 @@ The result should be a test project with a `.csproj` that looks like this (non b
226226
</PropertyGroup>
227227

228228
<ItemGroup>
229-
<PackageReference Include="bunit" Version="#{RELEASE-VERSION}#" />
229+
<PackageReference Include="bunit" Version="#{RELEASE_VERSION}#" />
230230
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
231231
<PackageReference Include="MSTest.TestAdapter" Version="3.0.2" />
232232
<PackageReference Include="MSTest.TestFramework" Version="3.0.2" />

src/Directory.Build.props

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,6 @@
2727
<PackageValidationBaselineVersion>1.25.3</PackageValidationBaselineVersion>
2828
</PropertyGroup>
2929

30-
<Target Name="SetPackageReleaseNotes" BeforeTargets="GenerateNuspec">
31-
<PropertyGroup>
32-
<PackageReleaseNotes>$([System.IO.File]::ReadAllText("$(MSBuildProjectDirectory)/../../CHANGELOG.md"))</PackageReleaseNotes>
33-
</PropertyGroup>
34-
</Target>
35-
3630
<PropertyGroup Label="NuGet package information">
3731
<PackageLicenseExpression>MIT</PackageLicenseExpression>
3832
<RepositoryUrl>https://github.com/bUnit-dev/bUnit</RepositoryUrl>
@@ -46,6 +40,7 @@
4640
<PublishRepositoryUrl>true</PublishRepositoryUrl>
4741
<PackageIcon>bunit-logo.png</PackageIcon>
4842
<PackageReadmeFile>README.md</PackageReadmeFile>
43+
<PackageReleaseNotes>#{RELEASE_NOTES}#</PackageReleaseNotes>
4944
</PropertyGroup>
5045

5146
<ItemGroup>

src/bunit.template/template/Company.BlazorTests1.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
</ItemGroup>
1717

1818
<ItemGroup>
19-
<PackageReference Include="bunit" Version="#{NBGV_NuGetPackageVersion}#" />
19+
<PackageReference Include="bunit" Version="#{RELEASE_VERSION}#" />
2020
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
2121
<PackageReference Include="coverlet.collector" Version="6.0.0">
2222
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>

0 commit comments

Comments
 (0)