-
Notifications
You must be signed in to change notification settings - Fork 417
320 lines (266 loc) · 14.4 KB
/
dotnet-build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
name: Build Libraries + Samples
on:
push:
branches:
- main
tags:
- '*'
paths-ignore:
- README.md
pull_request:
branches:
- main
paths-ignore:
- README.md
env:
CurrentSemanticVersionBase: '99.0.0'
PreviewNumber: ${{ github.run_number }}
CurrentSemanticVersion: '99.0.0-preview${{ github.run_number }}'
NugetPackageVersion: '99.0.0-preview${{ github.run_number }}'
NugetPackageVersionCamera: '99.0.0-preview${{ github.run_number }}'
NugetPackageVersionMediaElement: '99.0.0-preview${{ github.run_number }}'
NugetPackageVersionMaps: '99.0.0-preview${{ github.run_number }}'
TOOLKIT_NET_VERSION: '9.0.102'
LATEST_NET_VERSION: '9.0.x'
PathToLibrarySolution: 'src/CommunityToolkit.Maui.sln'
PathToSamplesSolution: 'samples/CommunityToolkit.Maui.Sample.sln'
PathToCommunityToolkitCsproj: 'src/CommunityToolkit.Maui/CommunityToolkit.Maui.csproj'
PathToCommunityToolkitCoreCsproj: 'src/CommunityToolkit.Maui.Core/CommunityToolkit.Maui.Core.csproj'
PathToCommunityToolkitCameraCsproj: 'src/CommunityToolkit.Maui.Camera/CommunityToolkit.Maui.Camera.csproj'
PathToCommunityToolkitMediaElementCsproj: 'src/CommunityToolkit.Maui.MediaElement/CommunityToolkit.Maui.MediaElement.csproj'
PathToCommunityToolkitMapsCsproj: 'src/CommunityToolkit.Maui.Maps/CommunityToolkit.Maui.Maps.csproj'
PathToCommunityToolkitSampleCsproj: 'samples/CommunityToolkit.Maui.Sample/CommunityToolkit.Maui.Sample.csproj'
PathToCommunityToolkitUnitTestCsproj: 'src/CommunityToolkit.Maui.UnitTests/CommunityToolkit.Maui.UnitTests.csproj'
PathToCommunityToolkitAnalyzersCsproj: 'src/CommunityToolkit.Maui.Analyzers/CommunityToolkit.Maui.Analyzers.csproj'
PathToCommunityToolkitCameraAnalyzersCsproj: 'src/CommunityToolkit.Maui.Camera.Analyzers/CommunityToolkit.Maui.Camera.Analyzers.csproj'
PathToCommunityToolkitMediaElementAnalyzersCsproj: 'src/CommunityToolkit.Maui.MediaElement.Analyzers/CommunityToolkit.Maui.MediaElement.Analyzers.csproj'
PathToCommunityToolkitSourceGeneratorsCsproj: 'src/CommunityToolkit.Maui.SourceGenerators/CommunityToolkit.Maui.SourceGenerators.csproj'
PathToCommunityToolkitSourceGeneratorsInternalCsproj: 'src/CommunityToolkit.Maui.SourceGenerators.Internal/CommunityToolkit.Maui.SourceGenerators.Internal.csproj'
PathToCommunityToolkitAnalyzersCodeFixCsproj: 'src/CommunityToolkit.Maui.Analyzers.CodeFixes/CommunityToolkit.Maui.Analyzers.CodeFixes.csproj'
PathToCommunityToolkitCameraAnalyzersCodeFixCsproj: 'src/CommunityToolkit.Maui.Camera.Analyzers.CodeFixes/CommunityToolkit.Maui.Camera.Analyzers.CodeFixes.csproj'
PathToCommunityToolkitMediaElementAnalyzersCodeFixCsproj: 'src/CommunityToolkit.Maui.MediaElement.Analyzers.CodeFixes/CommunityToolkit.Maui.MediaElement.Analyzers.CodeFixes.csproj'
PathToCommunityToolkitAnalyzersUnitTestCsproj: 'src/CommunityToolkit.Maui.Analyzers.UnitTests/CommunityToolkit.Maui.Analyzers.UnitTests.csproj'
PathToCommunityToolkitAnalyzersBenchmarkCsproj: 'src/CommunityToolkit.Maui.Analyzers.Benchmarks/CommunityToolkit.Maui.Analyzers.Benchmarks.csproj'
CommunityToolkitSampleApp_Xcode_Version: '16.2'
CommunityToolkitLibrary_Xcode_Version: '16.2'
jobs:
build_sample:
name: Build Sample App using Latest .NET SDK
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-latest, macos-15]
steps:
- name: Checkout code
uses: actions/checkout@main
- name: Set Xcode version
if: runner.os == 'macOS'
run: |
echo Installed Xcode Versions:
ls -al /Applications | grep Xcode
sudo xcode-select --switch /Applications/Xcode_${{ env.CommunityToolkitSampleApp_Xcode_Version }}.app/Contents/Developer
- name: Install Latest .NET SDK, v${{ env.LATEST_NET_VERSION }}
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.LATEST_NET_VERSION }}
dotnet-quality: 'ga'
- name: Install .NET MAUI Workload
run: |
dotnet workload install maui
dotnet workload update
- name: Install Tizen Workload
run: |
Invoke-WebRequest 'https://raw.githubusercontent.com/Samsung/Tizen.NET/main/workload/scripts/workload-install.ps1' -OutFile 'workload-install.ps1'
.\workload-install.ps1
shell: pwsh
- name: Display dotnet info
run: dotnet --info
- name: Build Community Toolkit Sample
run: dotnet build -c Release ${{ env.PathToCommunityToolkitSampleCsproj }}
build_library:
name: Build Library
runs-on: ${{ matrix.os }}
env:
VSTEST_TESTHOST_SHUTDOWN_TIMEOUT: 1100 # Fixes "The active test run was aborted. Reason: Test host process crashed"
strategy:
matrix:
os: [windows-latest, macos-15]
steps:
- name: Checkout code
uses: actions/checkout@main
- name: Set NuGet Version to Tag Number
if: startsWith(github.ref, 'refs/tags/') && !endsWith(github.ref, '-mediaelement')
run: echo "NugetPackageVersion=${{ github.ref }}" >> $GITHUB_ENV
- name: Set NuGet Version to Tag Number for Camera
if: startsWith(github.ref, 'refs/tags/') && endsWith(github.ref, '-camera')
run: echo "NugetPackageVersionCamera=${{ github.ref }}" >> $GITHUB_ENV
- name: Set NuGet Version to Tag Number for MediaElement
if: startsWith(github.ref, 'refs/tags/') && endsWith(github.ref, '-mediaelement')
run: echo "NugetPackageVersionMediaElement=${{ github.ref }}" >> $GITHUB_ENV
- name: Set NuGet Version to Tag Number for Maps
if: startsWith(github.ref, 'refs/tags/') && endsWith(github.ref, '-maps')
run: echo "NugetPackageVersionMaps=${{ github.ref }}" >> $GITHUB_ENV
- name: Set NuGet Version to PR Version
if: ${{ github.event_name == 'pull_request' }}
run: |
echo "NugetPackageVersion=${{ env.CurrentSemanticVersionBase }}-build-${{ github.event.pull_request.number }}.${{ github.run_number }}+${{ github.sha }}"
echo "NugetPackageVersionMediaElement=${{ env.CurrentSemanticVersionBase }}-build-${{ github.event.pull_request.number }}.${{ github.run_number }}+${{ github.sha }}"
echo "NugetPackageVersionMaps=${{ env.CurrentSemanticVersionBase }}-build-${{ github.event.pull_request.number }}.${{ github.run_number }}+${{ github.sha }}"
shell: bash
- name: Set Xcode version
if: runner.os == 'macOS'
run: |
echo Installed Xcode Versions:
ls -al /Applications | grep Xcode
sudo xcode-select --switch /Applications/Xcode_${{ env.CommunityToolkitLibrary_Xcode_Version }}.app/Contents/Developer
- name: Install .NET SDK v${{ env.TOOLKIT_NET_VERSION }}
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.TOOLKIT_NET_VERSION }}
dotnet-quality: 'ga'
- name: Install .NET MAUI Workload
run: |
dotnet workload install maui
dotnet workload update
- name: Install Tizen Workload
run: |
Invoke-WebRequest 'https://raw.githubusercontent.com/Samsung/Tizen.NET/main/workload/scripts/workload-install.ps1' -OutFile 'workload-install.ps1'
.\workload-install.ps1
shell: pwsh
- name: Display dotnet info
run: dotnet --info
- name: 'Build CommunityToolkit.Maui.Analyzers'
run: dotnet build ${{ env.PathToCommunityToolkitAnalyzersCsproj }} -c Release
- name: 'Build CommunityToolkit.Maui.Analyzers.CodeFixes'
run: dotnet build ${{ env.PathToCommunityToolkitAnalyzersCodeFixCsproj }} -c Release
- name: 'Build CommunityToolkit.Maui.Camera.Analyzers'
run: dotnet build ${{ env.PathToCommunityToolkitCameraAnalyzersCsproj }} -c Release
- name: 'Build CommunityToolkit.Maui.Camera.Analyzers.CodeFixes'
run: dotnet build ${{ env.PathToCommunityToolkitCameraAnalyzersCodeFixCsproj }} -c Release
- name: 'Build CommunityToolkit.Maui.MediaElement.Analyzers'
run: dotnet build ${{ env.PathToCommunityToolkitMediaElementAnalyzersCsproj }} -c Release
- name: 'Build CommunityToolkit.Maui.MediaElement.Analyzers.CodeFixes'
run: dotnet build ${{ env.PathToCommunityToolkitMediaElementAnalyzersCodeFixCsproj }} -c Release
- name: 'Build CommunityToolkit.Maui.SourceGenerators'
run: dotnet build ${{ env.PathToCommunityToolkitSourceGeneratorsCsproj }} -c Release
- name: 'Build CommunityToolkit.SourceGenerators.Internal'
run: dotnet build ${{ env.PathToCommunityToolkitSourceGeneratorsInternalCsproj }} -c Release
- name: 'Build CommunityToolkit.Maui.Camera'
run: dotnet build ${{ env.PathToCommunityToolkitCameraCsproj }} -c Release -p:PackageVersion=${{ env.NugetPackageVersionCamera }} -p:Version=${{ env.NugetPackageVersion }}
- name: 'Build CommunityToolkit.Maui.MediaElement'
run: dotnet build ${{ env.PathToCommunityToolkitMediaElementCsproj }} -c Release -p:PackageVersion=${{ env.NugetPackageVersionMediaElement }} -p:Version=${{ env.NugetPackageVersion }}
- name: 'Build CommunityToolkit.Maui.Maps'
run: dotnet build ${{ env.PathToCommunityToolkitMapsCsproj }} -c Release -p:PackageVersion=${{ env.NugetPackageVersionMaps }} -p:Version=${{ env.NugetPackageVersion }}
- name: 'Build CommunityToolkit.Maui.Core'
run: dotnet build ${{ env.PathToCommunityToolkitCoreCsproj }} -c Release -p:PackageVersion=${{ env.NugetPackageVersion }} -p:Version=${{ env.NugetPackageVersion }}
- name: 'Build CommunityToolkit.Maui'
run: dotnet build ${{ env.PathToLibrarySolution }} -c Release -p:PackageVersion=${{ env.NugetPackageVersion }} -p:Version=${{ env.NugetPackageVersion }}
- name: Run All Unit Tests
run: dotnet test -c Release ${{ env.PathToLibrarySolution }} --settings ".runsettings" --collect "XPlat code coverage" --logger trx --results-directory ${{ runner.temp }}
- name: Publish Test Results
if: runner.os == 'Windows'
uses: actions/upload-artifact@v4
with:
name: Test Results
path: |
${{ runner.temp }}/**/*.trx
- name: Pack CommunityToolkit.Maui.Core NuGet
run: dotnet pack -c Release ${{ env.PathToCommunityToolkitCoreCsproj }} -p:PackageVersion=${{ env.NugetPackageVersion }}
- name: Pack CommunityToolkit.Maui NuGet
run: dotnet pack -c Release ${{ env.PathToCommunityToolkitCsproj }} -p:PackageVersion=${{ env.NugetPackageVersion }}
- name: Pack CommunityToolkit.Maui.Camera NuGet
run: dotnet pack -c Release ${{ env.PathToCommunityToolkitCameraCsproj }} -p:PackageVersion=${{ env.NugetPackageVersionCamera }}
- name: Pack CommunityToolkit.Maui.MediaElement NuGet
run: dotnet pack -c Release ${{ env.PathToCommunityToolkitMediaElementCsproj }} -p:PackageVersion=${{ env.NugetPackageVersionMediaElement }}
- name: Pack CommunityToolkit.Maui.Maps NuGet
run: dotnet pack -c Release ${{ env.PathToCommunityToolkitMapsCsproj }} -p:PackageVersion=${{ env.NugetPackageVersionMaps }}
- name: Copy NuGet Packages to Staging Directory
if: runner.os == 'Windows' && !startsWith(github.ref, 'refs/tags/')
run: |
mkdir -p ${{ github.workspace }}/nuget
Get-ChildItem -Path "./src" -Recurse | Where-Object { $_.Extension -match "nupkg" } | Copy-Item -Destination "${{ github.workspace }}/nuget"
shell: pwsh
- name: Upload Package List
uses: actions/upload-artifact@v4
if: runner.os == 'Windows'
with:
name: nuget-list
if-no-files-found: error
path: |
${{ github.workspace }}/.github/workflows/SignClientFileList.txt
- name: Publish Packages
if: runner.os == 'Windows'
uses: actions/upload-artifact@v4
with:
name: packages
path: ${{ github.workspace }}/nuget/
sign:
needs: [build_library]
if: ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/rel/') }}
runs-on: windows-latest
permissions:
id-token: write # Required for requesting the JWT
steps:
- name: Install .NET SDK v${{ env.TOOLKIT_NET_VERSION }}
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.TOOLKIT_NET_VERSION }}
dotnet-quality: 'ga'
- name: Download NuGet List
uses: actions/download-artifact@v4
with:
name: nuget-list
path: ./
- name: Download Package List
uses: actions/download-artifact@v4
with:
name: packages
path: ./packages
- name: Install Signing Tool
run: dotnet tool install --tool-path ./tools sign --version 0.9.1-beta.23356.1
- name: Sign Packages
run: >
./tools/sign code azure-key-vault
**/*.nupkg
--base-directory "${{ github.workspace }}/packages"
--file-list "${{ github.workspace }}/SignClientFileList.txt"
--timestamp-url "http://timestamp.digicert.com"
--publisher-name ".NET Foundation"
--description "Community Toolkit MAUI"
--description-url "https://github.com/CommunityToolkit/Maui"
--azure-key-vault-url "${{ secrets.SIGN_KEY_VAULT_URL }}"
--azure-key-vault-client-id ${{ secrets.SIGN_CLIENT_ID }}
--azure-key-vault-client-secret "${{ secrets.SIGN_CLIENT_SECRET }}"
--azure-key-vault-tenant-id ${{ secrets.SIGN_TENANT_ID }}
--azure-key-vault-certificate "${{ secrets.SIGN_CERTIFICATE }}"
--verbosity Information
- name: Publish Packages
uses: actions/upload-artifact@v4
with:
name: signed-packages
if-no-files-found: error
path: |
${{ github.workspace }}/packages/**/*.nupkg
release:
if: ${{ startsWith(github.ref, 'refs/heads/rel/') }}
needs: [sign]
environment: nuget-release-gate # This gates this job until manually approved
runs-on: ubuntu-latest
steps:
- name: Install .NET SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.TOOLKIT_NET_VERSION }}
dotnet-quality: 'ga'
- name: Download signed packages for ${{ matrix.platform }}
uses: actions/download-artifact@v4
with:
name: signed-packages
path: ./packages
- name: Push to NuGet.org
run: >
dotnet nuget push
**/*.nupkg
--source https://api.nuget.org/v3/index.json
--api-key ${{ secrets.NUGET_PACKAGE_PUSH_TOKEN }}
--skip-duplicate