Skip to content

Commit 4e5a901

Browse files
committed
Add Windows builds and tests
1 parent c3eabaa commit 4e5a901

1 file changed

Lines changed: 77 additions & 1 deletion

File tree

.github/workflows/build.yml

Lines changed: 77 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323

2424
build-linux:
2525
name: Build and Test (Linux)
26-
runs-on: ubuntu-latest
26+
runs-on: ubuntu-22.04 # ubuntu-24.04 does not include mono needed for net4x tests
2727
defaults:
2828
run:
2929
working-directory: Src
@@ -60,3 +60,79 @@ jobs:
6060
flags: net10.0-linux
6161
name: net10.0-linux
6262
token: ${{ secrets.CODECOV_TOKEN }}
63+
64+
65+
build-windows:
66+
name: Build and Test (Windows)
67+
runs-on: windows-2022
68+
defaults:
69+
run:
70+
working-directory: Src
71+
72+
steps:
73+
- name: Checkout
74+
uses: actions/checkout@v6
75+
76+
- name: Configure Git line endings
77+
run: git config --global core.autocrlf true
78+
79+
- name: Setup .NET
80+
uses: actions/setup-dotnet@v5
81+
with:
82+
dotnet-version: |
83+
10.0.x
84+
85+
- name: Display .NET version
86+
run: dotnet --version
87+
88+
- name: Restore dependencies
89+
run: dotnet restore --verbosity quiet
90+
91+
- name: Add AltCover package
92+
run: dotnet add .\MailMergeLib.Tests\MailMergeLib.Tests.csproj package AltCover
93+
94+
- name: Determine version
95+
id: version
96+
shell: pwsh
97+
run: |
98+
$version = "${{ env.VERSION }}"
99+
$versionFile = "$version.${{ github.run_number }}"
100+
101+
if ("${{ github.event_name }}" -eq "pull_request") {
102+
$version = "$version-PR${{ github.event.pull_request.number }}"
103+
}
104+
105+
echo "VERSION=$version" >> $env:GITHUB_OUTPUT
106+
echo "FILE_VERSION=$versionFile" >> $env:GITHUB_OUTPUT
107+
echo "Package version: $version"
108+
echo "File version: $versionFile"
109+
110+
- name: Build solution
111+
run: dotnet build MailMergeLib.sln /verbosity:minimal /t:rebuild /p:configuration=release /p:IncludeSymbols=true /p:ContinuousIntegrationBuild=true /p:Version=${{ steps.version.outputs.VERSION }} /p:FileVersion=${{ steps.version.outputs.FILE_VERSION }}
112+
113+
- name: Run tests
114+
run: dotnet test --framework net10.0 --no-build --configuration release MailMergeLib.sln /p:AltCover=true /p:AltCoverXmlReport="coverage.xml" /p:AltCoverStrongNameKey="..\MailMergeLib\MailMergeLib.snk" /p:AltCoverAssemblyExcludeFilter="MailMergeLib.Tests|NUnit3.TestAdapter" /p:AltCoverLineCover="true"
115+
116+
- name: Upload coverage to Codecov
117+
uses: codecov/codecov-action@v5
118+
with:
119+
files: ./Src/MailMergeLib.Tests/coverage.net10.0.xml
120+
flags: net10.0-windows
121+
name: net10.0-windows
122+
token: ${{ secrets.CODECOV_TOKEN }}
123+
124+
- name: Pack NuGet packages
125+
run: dotnet pack MailMergeLib.sln --verbosity minimal --no-build --configuration release /p:IncludeSymbols=true /p:SymbolPackageFormat=snupkg /p:PackageOutputPath=${{ github.workspace }}/artifacts /p:ContinuousIntegrationBuild=true
126+
127+
- name: Upload NuGet packages as artifacts
128+
uses: actions/upload-artifact@v7
129+
with:
130+
name: nuget-packages
131+
path: |
132+
artifacts/*.nupkg
133+
artifacts/*.snupkg
134+
retention-days: 30
135+
136+
- name: Publish to NuGet
137+
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
138+
run: dotnet nuget push "artifacts/*.nupkg" --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate

0 commit comments

Comments
 (0)