1+ name : Build
2+
3+ on :
4+ push :
5+ branches :
6+ - main
7+ tags :
8+ - ' *'
9+ paths-ignore :
10+ - README.md
11+ pull_request :
12+ branches :
13+ - main
14+ paths-ignore :
15+ - README.md
16+
17+ pr :
18+ autoCancel : ' true'
19+ branches :
20+ include :
21+ - main
22+ paths :
23+ exclude :
24+ - README.md
25+
26+ env :
27+ CurrentSemanticVersionBase : ' 99.0.0'
28+ PreviewNumber : $[counter(variables['CurrentSemanticVersionBase'], 1001)]
29+ CurrentSemanticVersion : ' $(CurrentSemanticVersionBase)-preview$(PreviewNumber)'
30+ NugetPackageVersion : ' $(CurrentSemanticVersion)'
31+ NET_VERSION : ' 9.0.x'
32+ RunPoliCheck : false
33+ PathToLibrarySolution : ' src/CommunityToolkit.Maui.Markup.sln'
34+ PathToSamplesSolution : ' samples/CommunityToolkit.Maui.Markup.Sample.sln'
35+ PathToCommunityToolkitCsproj : ' src/CommunityToolkit.Maui.Markup/CommunityToolkit.Maui.Markup.csproj'
36+ PathToCommunityToolkitSampleCsproj : ' samples/CommunityToolkit.Maui.Markup.Sample/CommunityToolkit.Maui.Markup.Sample.csproj'
37+ PathToCommunityToolkitUnitTestCsproj : ' src/CommunityToolkit.Maui.Markup.UnitTests/CommunityToolkit.Maui.Markup.UnitTests.csproj'
38+ PathToCommunityToolkitSourceGeneratorsCsproj : ' src/CommunityToolkit.Maui.Markup.SourceGenerators/CommunityToolkit.Maui.Markup.SourceGenerators.csproj'
39+ Xcode_Version : ' 16.3'
40+ ShouldCheckDependencies : true
41+
42+ concurrency :
43+ group : ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
44+ cancel-in-progress : true
45+
46+ jobs :
47+ build_sample :
48+ name : Build Sample App using Latest .NET SDK
49+ runs-on : ${{ matrix.os }}
50+ strategy :
51+ fail-fast : false
52+ matrix :
53+ os : [windows-latest, macos-15]
54+ steps :
55+ - name : Checkout code
56+ uses : actions/checkout@main
57+
58+ - name : Set Latest Xcode Version
59+ if : runner.os == 'macOS'
60+ uses : maxim-lobanov/setup-xcode@v1
61+ with :
62+ xcode-version : latest-stable
63+
64+ - name : Install Latest .NET SDK, v${{ env.LATEST_NET_VERSION }}
65+ uses : actions/setup-dotnet@v4
66+ with :
67+ dotnet-version : ${{ env.LATEST_NET_VERSION }}
68+ dotnet-quality : ' ga'
69+
70+ - uses : actions/setup-java@v4
71+ with :
72+ distribution : ' microsoft'
73+ java-version : ' 17'
74+
75+ - name : Install .NET MAUI Workload
76+ run : |
77+ dotnet workload install maui
78+ dotnet workload update
79+
80+ - name : Install Tizen Workload
81+ run : |
82+ Invoke-WebRequest 'https://raw.githubusercontent.com/Samsung/Tizen.NET/main/workload/scripts/workload-install.ps1' -OutFile 'workload-install.ps1'
83+ .\workload-install.ps1
84+ shell : pwsh
85+
86+ - name : Display dotnet info
87+ run : dotnet --info
88+
89+ - name : Build CommunityToolkit.Maui.Markup.Sample
90+ run : dotnet build -c Release ${{ env.PathToCommunityToolkitSampleCsproj }}
91+
92+ build_library :
93+ name : Build Library
94+ runs-on : ${{ matrix.os }}
95+ strategy :
96+ fail-fast : false
97+ matrix :
98+ os : [windows-latest, macos-15]
99+ steps :
100+ - name : Checkout code
101+ uses : actions/checkout@main
102+
103+ - name : Set NuGet Version to Tag Number
104+ if : startsWith(github.ref, 'refs/tags/')
105+ run : echo "NugetPackageVersion=${{ github.ref }}" >> $GITHUB_ENV
106+
107+ - name : Set NuGet Version to PR Version
108+ if : ${{ github.event_name == 'pull_request' }}
109+ run : echo "NugetPackageVersion=${{ env.CurrentSemanticVersionBase }}-build-${{ github.event.pull_request.number }}.${{ github.run_number }}+${{ github.sha }}"
110+ shell : bash
111+
112+ - name : Set Xcode Version
113+ if : runner.os == 'macOS'
114+ uses : maxim-lobanov/setup-xcode@v1
115+ with :
116+ xcode-version : ${{ env.CommunityToolkitLibrary_Xcode_Version }}
117+
118+ - name : Install .NET SDK v${{ env.TOOLKIT_NET_VERSION }}
119+ uses : actions/setup-dotnet@v4
120+ with :
121+ dotnet-version : ${{ env.TOOLKIT_NET_VERSION }}
122+ dotnet-quality : ' ga'
123+
124+ - uses : actions/setup-java@v4
125+ with :
126+ distribution : ' microsoft'
127+ java-version : ' 17'
128+
129+ - name : Install .NET MAUI Workload
130+ run : |
131+ dotnet workload install maui
132+ dotnet workload update
133+
134+ - name : Install Tizen Workload
135+ run : |
136+ Invoke-WebRequest 'https://raw.githubusercontent.com/Samsung/Tizen.NET/main/workload/scripts/workload-install.ps1' -OutFile 'workload-install.ps1'
137+ .\workload-install.ps1
138+ shell : pwsh
139+
140+ - name : Display dotnet info
141+ run : dotnet --info
142+
143+ - name : ' Build CommunityToolkit.Maui.Markup.SourceGenerators'
144+ run : dotnet build ${{ env.PathToCommunityToolkitSourceGeneratorsCsproj }} -c Release
145+
146+ - name : ' Build CommunityToolkit.Maui.Markup'
147+ run : dotnet build ${{ env.PathToCommunityToolkitCsproj }} -c Release
148+
149+ - name : ' Build CommunityToolkit.Maui.Markup.UnitTests'
150+ run : dotnet build ${{ env.PathToCommunityToolkitUnitTestCsproj }} -c Release
151+
152+ - name : Run Unit Tests
153+ run : dotnet run -c Release --project $${{ env.PathToCommunityToolkitUnitTestCsproj }} --results-directory "${{ runner.temp }}" --coverage --coverage-output "${{ runner.temp }}/coverage.cobertura.xml" --coverage-output-format cobertura
154+
155+ - name : Publish Code Coverage Results
156+ if : ${{ runner.os == 'Windows' && (success() || failure()) }}
157+ run : |
158+ dotnet tool install -g dotnet-reportgenerator-globaltool
159+ reportgenerator -reports:'${{ runner.temp }}\*cobertura.xml' -targetdir:CodeCoverage -reporttypes:'MarkdownSummaryGithub'
160+ cat CodeCoverage/SummaryGithub.md >> $GITHUB_STEP_SUMMARY
161+ shell : bash
162+
163+ - name : Build and Pack CommunityToolkit.Maui.Markup
164+ run : dotnet pack -c Release ${{ env.PathToCommunityToolkitCsproj }} -p:PackageVersion=${{ env.NugetPackageVersion }} -p:IncludeSymbols=true -p:SymbolPackageFormat=snupkg
165+
166+ - powershell : |
167+ cd src
168+ dotnet list package --include-transitive # Print all transitive packages
169+ dotnet list package --vulnerable --include-transitive | findstr /S /c:"has the following vulnerable packages"; # Print all transitive packages with vulnerabilities
170+ if ($LastExitCode -ne 1)
171+ {
172+ dotnet list package --vulnerable --include-transitive;
173+ exit 1;
174+ }
175+
176+ exit 0;
177+ displayName: 'Check Dependencies'
178+ condition: eq(variables['Agent.OS'], 'Windows_NT') # Only run this step on Windows
179+
180+ - name : Copy NuGet Packages to Staging Directory
181+ if : ${{ runner.os == 'Windows' }} && !startsWith(github.ref, 'refs/tags/')
182+ run : |
183+ mkdir -p ${{ github.workspace }}/nuget
184+ Get-ChildItem -Path "./src" -Recurse | Where-Object { $_.Extension -match "nupkg" } | Copy-Item -Destination "${{ github.workspace }}/nuget"
185+ shell : pwsh
186+
187+ - name : Upload Package List
188+ uses : actions/upload-artifact@v4
189+ if : ${{ runner.os == 'Windows' }}
190+ with :
191+ name : nuget-list
192+ if-no-files-found : error
193+ path : |
194+ ${{ github.workspace }}/.github/workflows/SignClientFileList.txt
195+
196+ - name : Publish Packages
197+ if : ${{ runner.os == 'Windows' }}
198+ uses : actions/upload-artifact@v4
199+ with :
200+ name : packages
201+ path : ${{ github.workspace }}/nuget/
202+
203+ sign :
204+ needs : [build_library]
205+ if : ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/rel/') }}
206+ runs-on : windows-latest
207+ permissions :
208+ id-token : write # Required for requesting the JWT
209+
210+ steps :
211+ - name : Install .NET SDK v${{ env.TOOLKIT_NET_VERSION }}
212+ uses : actions/setup-dotnet@v4
213+ with :
214+ dotnet-version : ${{ env.TOOLKIT_NET_VERSION }}
215+ dotnet-quality : ' ga'
216+
217+ - name : Download NuGet List
218+ uses : actions/download-artifact@v4
219+ with :
220+ name : nuget-list
221+ path : ./
222+
223+ - name : Download Package List
224+ uses : actions/download-artifact@v4
225+ with :
226+ name : packages
227+ path : ./packages
228+
229+ - name : Install Signing Tool
230+ run : dotnet tool install --tool-path ./tools sign --version 0.9.1-beta.23356.1
231+
232+ - name : Sign Packages
233+ run : >
234+ ./tools/sign code azure-key-vault
235+ **/*.nupkg
236+ --base-directory "${{ github.workspace }}/packages"
237+ --file-list "${{ github.workspace }}/SignClientFileList.txt"
238+ --timestamp-url "http://timestamp.digicert.com"
239+ --publisher-name ".NET Foundation"
240+ --description "Community Toolkit MAUI"
241+ --description-url "https://github.com/CommunityToolkit/Maui"
242+ --azure-key-vault-url "${{ secrets.SIGN_KEY_VAULT_URL }}"
243+ --azure-key-vault-client-id ${{ secrets.SIGN_CLIENT_ID }}
244+ --azure-key-vault-client-secret "${{ secrets.SIGN_CLIENT_SECRET }}"
245+ --azure-key-vault-tenant-id ${{ secrets.SIGN_TENANT_ID }}
246+ --azure-key-vault-certificate "${{ secrets.SIGN_CERTIFICATE }}"
247+ --verbosity Information
248+
249+ - name : Publish Packages
250+ uses : actions/upload-artifact@v4
251+ with :
252+ name : signed-packages
253+ if-no-files-found : error
254+ path : |
255+ ${{ github.workspace }}/packages/**/*.nupkg
256+
257+ release :
258+ if : ${{ startsWith(github.ref, 'refs/heads/rel/') }}
259+ needs : [sign]
260+ environment : nuget-release-gate # This gates this job until manually approved
261+ runs-on : ubuntu-latest
262+
263+ steps :
264+ - name : Install .NET SDK
265+ uses : actions/setup-dotnet@v4
266+ with :
267+ dotnet-version : ${{ env.TOOLKIT_NET_VERSION }}
268+ dotnet-quality : ' ga'
269+
270+ - name : Download signed packages for ${{ matrix.platform }}
271+ uses : actions/download-artifact@v4
272+ with :
273+ name : signed-packages
274+ path : ./packages
275+
276+ - name : Push to NuGet.org
277+ run : >
278+ dotnet nuget push
279+ **/*.nupkg
280+ --source https://api.nuget.org/v3/index.json
281+ --api-key ${{ secrets.NUGET_PACKAGE_PUSH_TOKEN }}
282+ --skip-duplicate
0 commit comments