1
+ name : CI Build (Optimized)
2
+
3
+ on :
4
+ push :
5
+ branches :
6
+ - master
7
+ - ' release/**'
8
+ - ' maintenance/**'
9
+ paths-ignore :
10
+ - ' **/*.png'
11
+ - ' **/*.md'
12
+ workflow_dispatch :
13
+
14
+ env :
15
+ DOTNET_SKIP_FIRST_TIME_EXPERIENCE : true
16
+ DOTNET_CLI_TELEMETRY_OPTOUT : true
17
+
18
+ jobs :
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
+ 8.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 : Publish Standard NuGets
96
+ if : github.ref == 'refs/heads/master' && github.repository_owner == 'angularsen'
97
+ run : |
98
+ echo "::group::Publishing Standard NuGets to nuget.org..."
99
+ dotnet nuget push "Artifacts/NuGet/*.nupkg" \
100
+ --skip-duplicate \
101
+ --api-key ${{ secrets.NUGET_ORG_APIKEY }} \
102
+ --source https://api.nuget.org/v3/index.json
103
+ echo "::endgroup::"
104
+
105
+ nano-build :
106
+ name : Nano - Build (Windows)
107
+ runs-on : windows-latest
108
+ needs : [] # Run in parallel, no dependencies
109
+
110
+ steps :
111
+ - name : Checkout
112
+ uses : actions/checkout@v4
113
+ with :
114
+ fetch-depth : 1
115
+ lfs : true
116
+
117
+ - name : Setup .NET SDK
118
+ uses : actions/setup-dotnet@v4
119
+ with :
120
+ dotnet-version : |
121
+ 6.0.x
122
+ 8.0.x
123
+
124
+ - name : Setup .NET nanoFramework
125
+ uses : nanoframework/nanobuild@v1
126
+ with :
127
+ workload : ' nanoFramework'
128
+
129
+ - name : Generate Code
130
+ shell : pwsh
131
+ run : dotnet run --project CodeGen
132
+
133
+ - name : Build Nano Projects
134
+ shell : pwsh
135
+ run : |
136
+ Write-Host "::group::Building NanoFramework projects..."
137
+
138
+ # Build NanoFramework projects with MSBuild
139
+ $msbuildPath = & "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" `
140
+ -latest -requires Microsoft.Component.MSBuild `
141
+ -find MSBuild\**\Bin\MSBuild.exe | Select-Object -First 1
142
+
143
+ if (-not $msbuildPath) {
144
+ Write-Error "MSBuild not found. Ensure Visual Studio Build Tools are installed."
145
+ exit 1
146
+ }
147
+
148
+ & $msbuildPath UnitsNet.NanoFramework/UnitsNet.NanoFramework.nfproj `
149
+ /p:Configuration=Release /p:Platform="Any CPU" /restore
150
+
151
+ & $msbuildPath UnitsNet.NumberExtensions.NanoFramework/UnitsNet.NumberExtensions.NanoFramework.nfproj `
152
+ /p:Configuration=Release /p:Platform="Any CPU" /restore
153
+
154
+ Write-Host "::endgroup::"
155
+
156
+ - name : Pack Nano NuGets
157
+ shell : pwsh
158
+ run : |
159
+ Write-Host "::group::Packing NanoFramework NuGets..."
160
+
161
+ $msbuildPath = & "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" `
162
+ -latest -requires Microsoft.Component.MSBuild `
163
+ -find MSBuild\**\Bin\MSBuild.exe | Select-Object -First 1
164
+
165
+ & $msbuildPath UnitsNet.NanoFramework/UnitsNet.NanoFramework.nfproj `
166
+ /t:Pack /p:Configuration=Release /p:PackageOutputPath="$PWD\Artifacts\NuGet"
167
+
168
+ & $msbuildPath UnitsNet.NumberExtensions.NanoFramework/UnitsNet.NumberExtensions.NanoFramework.nfproj `
169
+ /t:Pack /p:Configuration=Release /p:PackageOutputPath="$PWD\Artifacts\NuGet"
170
+
171
+ Write-Host "::endgroup::"
172
+
173
+ - name : Upload Nano NuGets
174
+ uses : actions/upload-artifact@v4
175
+ with :
176
+ name : nano-nugets
177
+ path : |
178
+ Artifacts/NuGet/*.nupkg
179
+ Artifacts/NuGet/*.snupkg
180
+ retention-days : 30
181
+
182
+ - name : Publish Nano NuGets
183
+ if : github.ref == 'refs/heads/master' && github.repository_owner == 'angularsen'
184
+ shell : pwsh
185
+ run : |
186
+ Write-Host "::group::Publishing NanoFramework NuGets to nuget.org..."
187
+
188
+ dotnet nuget push "Artifacts\NuGet\*.nupkg" `
189
+ --skip-duplicate `
190
+ --api-key "${{ secrets.NUGET_ORG_APIKEY }}" `
191
+ --source https://api.nuget.org/v3/index.json
192
+
193
+ Write-Host "::endgroup::"
194
+
195
+ check-status :
196
+ name : Check Build Status
197
+ needs : [standard-build, nano-build]
198
+ runs-on : ubuntu-latest
199
+ if : always()
200
+
201
+ steps :
202
+ - name : Check Status
203
+ run : |
204
+ if [[ "${{ needs.standard-build.result }}" != "success" ]] || [[ "${{ needs.nano-build.result }}" != "success" ]]; then
205
+ echo "❌ One or more builds failed"
206
+ echo "Standard Build: ${{ needs.standard-build.result }}"
207
+ echo "Nano Build: ${{ needs.nano-build.result }}"
208
+ exit 1
209
+ fi
210
+ echo "✅ All builds succeeded"
0 commit comments