Skip to content

Commit 95edb2f

Browse files
add nuget publish task
keep dotnet version as 8.x
1 parent a7528ac commit 95edb2f

File tree

5 files changed

+55
-11
lines changed

5 files changed

+55
-11
lines changed

.github/workflows/build.yml

Lines changed: 54 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ name: Build and Test
22
on:
33
push:
44
pull_request:
5+
workflow_dispatch:
56

67
jobs:
78
build:
@@ -10,6 +11,26 @@ jobs:
1011
steps:
1112
- name: Checkout code
1213
uses: actions/checkout@v5
14+
with:
15+
fetch-depth: 0 # Required for GitVersion
16+
17+
- name: Install GitVersion
18+
uses: gittools/actions/gitversion/[email protected]
19+
with:
20+
versionSpec: '6.x'
21+
22+
- name: Determine Version
23+
uses: gittools/actions/gitversion/[email protected]
24+
id: gitversion
25+
with:
26+
useConfigFile: true
27+
28+
- name: Display GitVersion outputs
29+
run: |
30+
echo "Version: ${{ steps.gitversion.outputs.semVer }}"
31+
echo "AssemblyVersion: ${{ steps.gitversion.outputs.assemblySemVer }}"
32+
echo "FileVersion: ${{ steps.gitversion.outputs.assemblySemFileVer }}"
33+
echo "NuGet Version: ${{ steps.gitversion.outputs.nuGetVersionV2 }}"
1334
1435
- name: Setup .NET
1536
uses: actions/setup-dotnet@v5
@@ -18,7 +39,7 @@ jobs:
1839

1940
- name: Build project
2041
working-directory: src
21-
run: dotnet build --configuration Release
42+
run: dotnet build --configuration Release /p:Version=${{ steps.gitversion.outputs.assemblySemVer }} /p:AssemblyVersion=${{ steps.gitversion.outputs.assemblySemVer }} /p:FileVersion=${{ steps.gitversion.outputs.assemblySemFileVer }} /p:PackageVersion=${{ steps.gitversion.outputs.nuGetVersionV2 }}
2243

2344
- name: Run tests with coverage
2445
working-directory: src
@@ -31,14 +52,41 @@ jobs:
3152
targetdir: 'coverage-report'
3253
reporttypes: 'Html;Cobertura'
3354

34-
- name: Upload coverage to Codecov
35-
uses: codecov/codecov-action@v5
55+
- name: Create NuGet package
56+
working-directory: src
57+
run: dotnet pack --configuration Release --no-build /p:PackageVersion=${{ steps.gitversion.outputs.nuGetVersionV2 }} --output ../packages
58+
59+
- name: Upload NuGet package as artifact
60+
uses: actions/upload-artifact@v4
3661
with:
37-
files: ./coverage/**/coverage.cobertura.xml
38-
fail_ci_if_error: false
62+
name: nuget-package
63+
path: packages/*.nupkg
3964

4065
- name: Publish coverage report as artifact
4166
uses: actions/upload-artifact@v4
4267
with:
4368
name: coverage-report
44-
path: coverage-report/
69+
path: coverage-report/
70+
71+
publish-nuget:
72+
runs-on: ubuntu-latest
73+
needs: build
74+
if: github.event_name == 'push' && github.ref_name == github.event.repository.default_branch
75+
environment:
76+
name: Publish
77+
url: https://www.nuget.org/packages/TestStack.BDDfy/
78+
79+
steps:
80+
- name: Download NuGet package
81+
uses: actions/download-artifact@v5
82+
with:
83+
name: nuget-package
84+
path: packages
85+
86+
- name: Setup .NET
87+
uses: actions/setup-dotnet@v5
88+
with:
89+
dotnet-version: '8.0.x'
90+
91+
- name: Publish to NuGet
92+
run: dotnet nuget push packages/*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate

src/Samples/TestStack.BDDfy.Samples/TestStack.BDDfy.Samples.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>net8.0</TargetFrameworks>
54
<AssemblyName>TestStack.BDDfy.Samples</AssemblyName>
65
<PackageId>TestStack.BDDfy.Samples</PackageId>
76
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>

src/TestStack.BDDfy.Tests/TestStack.BDDfy.Tests.csproj

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
<Project Sdk="Microsoft.NET.Sdk">
2-
32
<PropertyGroup>
4-
<TargetFrameworks>net8.0</TargetFrameworks>
53
<AssemblyName>TestStack.BDDfy.Tests</AssemblyName>
64
<PackageId>TestStack.BDDfy.Tests</PackageId>
75
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>

src/TestStack.BDDfy.sln

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
1313
..\build.ps1 = ..\build.ps1
1414
..\deploy.cake = ..\deploy.cake
1515
..\deploy.ps1 = ..\deploy.ps1
16+
..\Directory.build.props = ..\Directory.build.props
1617
..\GitVersion.yml = ..\GitVersion.yml
1718
..\license.txt = ..\license.txt
1819
..\logo.png = ..\logo.png

src/TestStack.BDDfy/TestStack.BDDfy.csproj

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
<Project Sdk="Microsoft.NET.Sdk">
2-
32
<PropertyGroup>
4-
<TargetFrameworks>net8.0</TargetFrameworks>
53
<AssemblyName>TestStack.BDDfy</AssemblyName>
64
<PackageId>TestStack.BDDfy</PackageId>
75
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>

0 commit comments

Comments
 (0)