Skip to content

Commit f640429

Browse files
committed
Add GitHub Actions
1 parent 21f14ef commit f640429

File tree

3 files changed

+370
-0
lines changed

3 files changed

+370
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
**/CommunityToolkit.*

.github/workflows/benchmarks.yml

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
name: Benchmarks
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
tags:
8+
- '*'
9+
paths-ignore:
10+
- README.md
11+
pull_request:
12+
branches:
13+
- '*'
14+
15+
env:
16+
LATEST_NET_VERSION: '9.0.x'
17+
PathToCommunityToolkitBenchmarkCsproj: 'src/CommunityToolkit.Maui.Markup.Benchmarks/CommunityToolkit.Maui.Markup.Benchmarks.csproj'
18+
19+
concurrency:
20+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
21+
cancel-in-progress: true
22+
23+
jobs:
24+
job: run_benchmarks
25+
displayName: Run Benchmarks
26+
strategy:
27+
matrix:
28+
'Windows':
29+
image: 'windows-latest'
30+
'macOS':
31+
image: 'macos-15'
32+
pool:
33+
vmImage: $(image)
34+
steps:
35+
- task: CmdLine@2
36+
displayName: 'Set Xcode v$(Xcode_Version)'
37+
condition: eq(variables['Agent.OS'], 'Darwin') # Only run this step on macOS
38+
inputs:
39+
script: |
40+
echo Installed Xcode Versions:
41+
ls -al /Applications | grep Xcode
42+
43+
echo '##vso[task.setvariable variable=MD_APPLE_SDK_ROOT;]'/Applications/Xcode_$(Xcode_Version).app
44+
sudo xcode-select --switch /Applications/Xcode_$(Xcode_Version).app/Contents/Developer
45+
46+
xcodebuild -downloadPlatform iOS
47+
48+
echo Installed Simulator SDKs:
49+
xcodebuild -showsdks
50+
51+
- task: UseDotNet@2
52+
displayName: 'Install .NET SDK'
53+
inputs:
54+
packageType: 'sdk'
55+
version: '$(NET_VERSION)'
56+
includePreviewVersions: false
57+
58+
- task: CmdLine@2
59+
displayName: 'Install .NET MAUI Workload'
60+
inputs:
61+
script : 'dotnet workload install maui'
62+
63+
- pwsh: |
64+
Invoke-WebRequest 'https://raw.githubusercontent.com/Samsung/Tizen.NET/main/workload/scripts/workload-install.ps1' -OutFile 'workload-install.ps1'
65+
.\workload-install.ps1
66+
displayName: Install Tizen Workload
67+
68+
# Print Information on the .NET SDK Used By the CI Build Host
69+
# These logs are useful information when debugging CI Builds
70+
# Note: This step doesn't execute nor modify any code; it is strictly used for logging + debugging purposes
71+
- task: CmdLine@2
72+
displayName: 'Display dotnet --info'
73+
inputs:
74+
script: dotnet --info
75+
76+
- task: CmdLine@2
77+
displayName: 'Run Benchmarks'
78+
inputs:
79+
script : 'dotnet run --project $(PathToCommunityToolkitBenchmarkCsproj) -c Release -- -a $(Build.ArtifactStagingDirectory)'
80+
81+
# publish the Benchmark Results
82+
- task: PublishBuildArtifacts@1
83+
condition: eq(variables['Agent.OS'], 'Windows_NT') # Only run this step on Windows
84+
displayName: 'Publish Benchmark Artifacts'
85+
inputs:
86+
artifactName: benchmarks
87+
pathToPublish: '$(Build.ArtifactStagingDirectory)'

.github/workflows/dotnet-build.yml

Lines changed: 282 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,282 @@
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

Comments
 (0)