1616 DOTNET_CLI_TELEMETRY_OPTOUT : true
1717
1818jobs :
19- build-and-test :
20- name : Build & Test
19+ standard-build :
20+ name : Standard - Build & Test (Linux)
21+ runs-on : ubuntu-latest
22+ outputs :
23+ version : ${{ steps.version.outputs.version }}
24+
25+ steps :
26+ - name : Checkout
27+ uses : actions/checkout@v4
28+ with :
29+ fetch-depth : 1
30+ lfs : true
31+
32+ - name : Setup .NET SDK
33+ uses : actions/setup-dotnet@v4
34+ with :
35+ dotnet-version : |
36+ 6.0.x
37+ 9.0.x
38+
39+ - name : Get Version
40+ id : version
41+ run : |
42+ VERSION=$(grep -oP '(?<=<Version>)[^<]+' UnitsNet/UnitsNet.csproj | head -1)
43+ echo "version=$VERSION" >> $GITHUB_OUTPUT
44+
45+ - name : Generate Code
46+ run : dotnet run --project CodeGen
47+
48+ - name : Build Projects
49+ run : |
50+ echo "::group::Building Standard projects..."
51+ dotnet build UnitsNet.slnx --configuration Release
52+ echo "::endgroup::"
53+
54+ - name : Run Tests
55+ run : |
56+ echo "::group::Running tests..."
57+ dotnet test UnitsNet.slnx --configuration Release --no-build \
58+ --collect:"XPlat Code Coverage" \
59+ --logger:trx \
60+ --results-directory "Artifacts/TestResults"
61+ echo "::endgroup::"
62+
63+ - name : Pack NuGets
64+ run : |
65+ echo "::group::Packing Standard NuGets..."
66+ dotnet pack UnitsNet.slnx --configuration Release --no-build \
67+ --output Artifacts/NuGet
68+ echo "::endgroup::"
69+
70+ - name : Upload Test Results
71+ uses : actions/upload-artifact@v4
72+ if : always()
73+ with :
74+ name : standard-test-results
75+ path : Artifacts/TestResults/*.trx
76+ retention-days : 30
77+
78+ - name : Upload Coverage
79+ uses : codecov/codecov-action@v4
80+ with :
81+ token : ${{ secrets.CODECOV_TOKEN }}
82+ files : Artifacts/TestResults/**/*.xml
83+ flags : standard
84+ name : standard-coverage
85+
86+ - name : Upload Standard NuGets
87+ uses : actions/upload-artifact@v4
88+ with :
89+ name : standard-nugets
90+ path : |
91+ Artifacts/NuGet/*.nupkg
92+ Artifacts/NuGet/*.snupkg
93+ retention-days : 30
94+
95+ - name : Upload Artifacts
96+ uses : actions/upload-artifact@v4
97+ with :
98+ name : standard-artifacts
99+ path : Artifacts/
100+ retention-days : 30
101+
102+ nano-build :
103+ name : Nano - Build (Windows)
21104 runs-on : windows-latest
105+ needs : [] # Run in parallel, no dependencies
22106
23107 steps :
24108 - name : Checkout
@@ -34,69 +118,83 @@ jobs:
34118 6.0.x
35119 9.0.x
36120
37- - name : Setup .NET nanoFramework build components
121+ - name : Setup .NET nanoFramework
38122 uses : nanoframework/nanobuild@v1
39123 with :
40124 workload : ' nanoFramework'
41125
42- - name : Build, Test and Pack
126+ - name : Generate Code
43127 shell : pwsh
44- run : |
45- ./Build/build.ps1 -IncludeNanoFramework
46- working-directory : ${{ github.workspace }}
128+ run : dotnet run --project CodeGen
47129
48- - name : Upload to codecov.io
130+ - name : Build Nano Projects
49131 shell : pwsh
50- env :
51- CODECOV_TOKEN : ${{ secrets.CODECOV_TOKEN }}
52132 run : |
53- Write-Host -Foreground Green "Downloading codecov binaries ..."
133+ Write-Host "::group::Building NanoFramework projects ..."
54134
55- Invoke-WebRequest -Uri https://uploader.codecov.io/verification.gpg -OutFile codecov.asc
56- gpg.exe --import codecov.asc
135+ # Build NanoFramework projects with MSBuild
136+ $msbuildPath = & "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" `
137+ -latest -requires Microsoft.Component.MSBuild `
138+ -find MSBuild\**\Bin\MSBuild.exe | Select-Object -First 1
57139
58- Invoke-WebRequest -Uri https://uploader.codecov.io/latest/windows/codecov.exe -Outfile codecov.exe
59- Invoke-WebRequest -Uri https://uploader.codecov.io/latest/windows/codecov.exe.SHA256SUM -Outfile codecov.exe.SHA256SUM
60- Invoke-WebRequest -Uri https://uploader.codecov.io/latest/windows/codecov.exe.SHA256SUM.sig -Outfile codecov.exe.SHA256SUM.sig
140+ if (-not $msbuildPath) {
141+ Write-Error "MSBuild not found. Ensure Visual Studio Build Tools are installed."
142+ exit 1
143+ }
61144
62- gpg.exe --verify codecov.exe.SHA256SUM.sig codecov.exe.SHA256SUM
63- If ($(Compare-Object -ReferenceObject $(($(certUtil -hashfile codecov.exe SHA256)[1], "codecov.exe") -join " ") -DifferenceObject $(Get-Content codecov.exe.SHA256SUM)).length -eq 0) { echo "SHASUM verified" } Else {exit 1}
145+ & $msbuildPath UnitsNet.NanoFramework/UnitsNet.NanoFramework.nfproj `
146+ /p:Configuration=Release /p:Platform="Any CPU" /restore
64147
65- Write-Host -Foreground Green "Uploading to codecov..."
148+ & $msbuildPath UnitsNet.NumberExtensions.NanoFramework/UnitsNet.NumberExtensions.NanoFramework.nfproj `
149+ /p:Configuration=Release /p:Platform="Any CPU" /restore
66150
67- .\codecov.exe --dir "Artifacts/Coverage" -t "$env:CODECOV_TOKEN" --build "${{ github.run_number }} "
151+ Write-Host "::endgroup:: "
68152
69- Write-Host -Foreground Green "✅ Uploaded to codecov."
153+ - name : Pack Nano NuGets
154+ shell : pwsh
155+ run : |
156+ Write-Host "::group::Packing NanoFramework NuGets..."
70157
71- - name : Upload Artifacts
72- uses : actions/upload-artifact@v4
73- with :
74- name : artifacts
75- path : Artifacts/
76- retention-days : 30
158+ $msbuildPath = & "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" `
159+ -latest -requires Microsoft.Component.MSBuild `
160+ -find MSBuild\**\Bin\MSBuild.exe | Select-Object -First 1
77161
78- - name : Upload NuGet packages
162+ & $msbuildPath UnitsNet.NanoFramework/UnitsNet.NanoFramework.nfproj `
163+ /t:Pack /p:Configuration=Release /p:PackageOutputPath="$PWD\Artifacts\NuGet"
164+
165+ & $msbuildPath UnitsNet.NumberExtensions.NanoFramework/UnitsNet.NumberExtensions.NanoFramework.nfproj `
166+ /t:Pack /p:Configuration=Release /p:PackageOutputPath="$PWD\Artifacts\NuGet"
167+
168+ Write-Host "::endgroup::"
169+
170+ - name : Upload Nano NuGets
79171 uses : actions/upload-artifact@v4
80172 with :
81- name : nuget-packages
173+ name : nano-nugets
82174 path : |
83- Artifacts/** /*.nupkg
84- Artifacts/** /*.snupkg
175+ Artifacts/NuGet /*.nupkg
176+ Artifacts/NuGet /*.snupkg
85177 retention-days : 30
86178
87179 publish-nuget :
88180 name : Publish to NuGet
89- needs : build-and-test
181+ needs : [standard- build, nano-build]
90182 runs-on : ubuntu-latest
91183 if : github.ref == 'refs/heads/master' && github.repository_owner == 'angularsen'
92184 environment : Publish
93185
94186 steps :
95- - name : Download NuGet packages
187+ - name : Download Standard NuGets
96188 uses : actions/download-artifact@v4
97189 with :
98- name : nuget-packages
99- path : nugets
190+ name : standard-nugets
191+ path : nugets/standard
192+
193+ - name : Download Nano NuGets
194+ uses : actions/download-artifact@v4
195+ with :
196+ name : nano-nugets
197+ path : nugets/nano
100198
101199 - name : Setup .NET SDK
102200 uses : actions/setup-dotnet@v4
@@ -107,5 +205,24 @@ jobs:
107205 env :
108206 NUGET_ORG_APIKEY : ${{ secrets.NUGET_ORG_APIKEY }}
109207 run : |
208+ echo "::group::Publishing all NuGets to nuget.org..."
110209 dotnet nuget push "**/*.nupkg" --skip-duplicate --api-key $NUGET_ORG_APIKEY --source https://api.nuget.org/v3/index.json
210+ echo "::endgroup::"
111211 working-directory : nugets
212+
213+ check-status :
214+ name : Check Build Status
215+ needs : [standard-build, nano-build]
216+ runs-on : ubuntu-latest
217+ if : always()
218+
219+ steps :
220+ - name : Check Status
221+ run : |
222+ if [[ "${{ needs.standard-build.result }}" != "success" ]] || [[ "${{ needs.nano-build.result }}" != "success" ]]; then
223+ echo "❌ One or more builds failed"
224+ echo "Standard Build: ${{ needs.standard-build.result }}"
225+ echo "Nano Build: ${{ needs.nano-build.result }}"
226+ exit 1
227+ fi
228+ echo "✅ All builds succeeded"
0 commit comments