Skip to content

Commit c56245e

Browse files
Use GitHub Actions
1 parent 816e8a7 commit c56245e

File tree

2 files changed

+182
-440
lines changed

2 files changed

+182
-440
lines changed

.github/workflows/dotnet-build.yml

Lines changed: 182 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,182 @@
1+
name: .NET
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+
env:
18+
CurrentSemanticVersionBase: '99.0.0'
19+
PreviewNumber: ${{ github.run_number }}
20+
CurrentSemanticVersion: '99.0.0-preview${{ github.run_number }}'
21+
NugetPackageVersion: '99.0.0-preview${{ github.run_number }}'
22+
NugetPackageVersionCamera: '99.0.0-preview${{ github.run_number }}'
23+
NugetPackageVersionMediaElement: '99.0.0-preview${{ github.run_number }}'
24+
NugetPackageVersionMaps: '99.0.0-preview${{ github.run_number }}'
25+
TOOLKIT_NET_VERSION: '8.0.203'
26+
LATEST_NET_VERSION: '8.0.x'
27+
PathToLibrarySolution: 'src/CommunityToolkit.Maui.sln'
28+
PathToSamplesSolution: 'samples/CommunityToolkit.Maui.Sample.sln'
29+
PathToCommunityToolkitCsproj: 'src/CommunityToolkit.Maui/CommunityToolkit.Maui.csproj'
30+
PathToCommunityToolkitCoreCsproj: 'src/CommunityToolkit.Maui.Core/CommunityToolkit.Maui.Core.csproj'
31+
PathToCommunityToolkitCameraCsproj: 'src/CommunityToolkit.Maui.Camera/CommunityToolkit.Maui.Camera.csproj'
32+
PathToCommunityToolkitMediaElementCsproj: 'src/CommunityToolkit.Maui.MediaElement/CommunityToolkit.Maui.MediaElement.csproj'
33+
PathToCommunityToolkitMapsCsproj: 'src/CommunityToolkit.Maui.Maps/CommunityToolkit.Maui.Maps.csproj'
34+
PathToCommunityToolkitSampleCsproj: 'samples/CommunityToolkit.Maui.Sample/CommunityToolkit.Maui.Sample.csproj'
35+
PathToCommunityToolkitUnitTestCsproj: 'src/CommunityToolkit.Maui.UnitTests/CommunityToolkit.Maui.UnitTests.csproj'
36+
PathToCommunityToolkitAnalyzersCsproj: 'src/CommunityToolkit.Maui.Analyzers/CommunityToolkit.Maui.Analyzers.csproj'
37+
PathToCommunityToolkitCameraAnalyzersCsproj: 'src/CommunityToolkit.Maui.Camera.Analyzers/CommunityToolkit.Maui.Camera.Analyzers.csproj'
38+
PathToCommunityToolkitMediaElementAnalyzersCsproj: 'src/CommunityToolkit.Maui.MediaElement.Analyzers/CommunityToolkit.Maui.MediaElement.Analyzers.csproj'
39+
PathToCommunityToolkitSourceGeneratorsCsproj: 'src/CommunityToolkit.Maui.SourceGenerators/CommunityToolkit.Maui.SourceGenerators.csproj'
40+
PathToCommunityToolkitSourceGeneratorsInternalCsproj: 'src/CommunityToolkit.Maui.SourceGenerators.Internal/CommunityToolkit.Maui.SourceGenerators.Internal.csproj'
41+
PathToCommunityToolkitAnalyzersCodeFixCsproj: 'src/CommunityToolkit.Maui.Analyzers.CodeFixes/CommunityToolkit.Maui.Analyzers.CodeFixes.csproj'
42+
PathToCommunityToolkitCameraAnalyzersCodeFixCsproj: 'src/CommunityToolkit.Maui.Camera.Analyzers.CodeFixes/CommunityToolkit.Maui.Camera.Analyzers.CodeFixes.csproj'
43+
PathToCommunityToolkitMediaElementAnalyzersCodeFixCsproj: 'src/CommunityToolkit.Maui.MediaElement.Analyzers.CodeFixes/CommunityToolkit.Maui.MediaElement.Analyzers.CodeFixes.csproj'
44+
PathToCommunityToolkitAnalyzersUnitTestCsproj: 'src/CommunityToolkit.Maui.Analyzers.UnitTests/CommunityToolkit.Maui.Analyzers.UnitTests.csproj'
45+
DotNetMauiRollbackFile: 'https://maui.blob.core.windows.net/metadata/rollbacks/8.0.6.json'
46+
CommunityToolkitSampleApp_Xcode_Version: '15.2.0'
47+
CommunityToolkitLibrary_Xcode_Version: '15.3.0'
48+
49+
jobs:
50+
build_sample:
51+
name: Build Sample App using Latest .NET SDK
52+
runs-on: ${{ matrix.os }}
53+
strategy:
54+
matrix:
55+
os: [windows-latest, macos-14]
56+
steps:
57+
- name: Checkout code
58+
uses: actions/checkout@main
59+
60+
- name: Set Xcode version
61+
if: runner.os == 'macOS'
62+
run: |
63+
sudo xcode-select --switch /Applications/Xcode_${{ env.CommunityToolkitSampleApp_Xcode_Version }}.app/Contents/Developer
64+
65+
- name: Install Latest .NET SDK
66+
uses: actions/setup-dotnet@v3
67+
with:
68+
dotnet-version: ${{ env.LATEST_NET_VERSION }}
69+
70+
- name: Install .NET MAUI Workload
71+
run: dotnet workload install maui
72+
73+
- name: Install Tizen Workload
74+
run: |
75+
Invoke-WebRequest 'https://raw.githubusercontent.com/Samsung/Tizen.NET/main/workload/scripts/workload-install.ps1' -OutFile 'workload-install.ps1'
76+
.\workload-install.ps1
77+
shell: pwsh
78+
79+
- name: Display dotnet info
80+
run: dotnet --info
81+
82+
- name: Build Community Toolkit Sample
83+
run: dotnet build -c Release ${{ env.PathToCommunityToolkitSampleCsproj }}
84+
85+
build_library:
86+
name: Build Library
87+
runs-on: ${{ matrix.os }}
88+
strategy:
89+
matrix:
90+
os: [windows-latest, macos-14]
91+
steps:
92+
- name: Checkout code
93+
uses: actions/checkout@main
94+
95+
- name: Set NuGet Version to Tag Number
96+
if: startsWith(github.ref, 'refs/tags/') && !endsWith(github.ref, '-mediaelement')
97+
run: echo "NugetPackageVersion=${{ github.ref }}" >> $GITHUB_ENV
98+
99+
- name: Set NuGet Version to Tag Number for Camera
100+
if: startsWith(github.ref, 'refs/tags/') && endsWith(github.ref, '-camera')
101+
run: echo "NugetPackageVersionCamera=${{ github.ref }}" >> $GITHUB_ENV
102+
103+
- name: Set NuGet Version to Tag Number for MediaElement
104+
if: startsWith(github.ref, 'refs/tags/') && endsWith(github.ref, '-mediaelement')
105+
run: echo "NugetPackageVersionMediaElement=${{ github.ref }}" >> $GITHUB_ENV
106+
107+
- name: Set NuGet Version to Tag Number for Maps
108+
if: startsWith(github.ref, 'refs/tags/') && endsWith(github.ref, '-maps')
109+
run: echo "NugetPackageVersionMaps=${{ github.ref }}" >> $GITHUB_ENV
110+
111+
- name: Set NuGet Version to PR Version
112+
if: ${{ github.event_name == 'pull_request' }}
113+
run: |
114+
echo "NugetPackageVersion=${{ env.CurrentSemanticVersionBase }}-build-${{ github.event.pull_request.number }}.${{ github.run_number }}+${{ github.sha }}"
115+
echo "NugetPackageVersionMediaElement=${{ env.CurrentSemanticVersionBase }}-build-${{ github.event.pull_request.number }}.${{ github.run_number }}+${{ github.sha }}"
116+
echo "NugetPackageVersionMaps=${{ env.CurrentSemanticVersionBase }}-build-${{ github.event.pull_request.number }}.${{ github.run_number }}+${{ github.sha }}"
117+
shell: bash
118+
119+
- name: Set Xcode version
120+
if: runner.os == 'macOS'
121+
run: |
122+
sudo xcode-select --switch /Applications/Xcode_${{ env.CommunityToolkitLibrary_Xcode_Version }}.app/Contents/Developer
123+
124+
- name: Install .NET SDK
125+
uses: actions/setup-dotnet@v3
126+
with:
127+
dotnet-version: ${{ env.TOOLKIT_NET_VERSION }}
128+
129+
- name: Install .NET MAUI Workload
130+
run: dotnet workload install maui --skip-sign-check --source https://api.nuget.org/v3/index.json
131+
132+
- name: Install Tizen Workload
133+
run: |
134+
Invoke-WebRequest 'https://raw.githubusercontent.com/Samsung/Tizen.NET/main/workload/scripts/workload-install.ps1' -OutFile 'workload-install.ps1'
135+
.\workload-install.ps1
136+
shell: pwsh
137+
138+
- name: Display dotnet info
139+
run: dotnet --info
140+
141+
- name: Build CommunityToolkit.Maui
142+
run: dotnet build -c Release ${{ env.PathToLibrarySolution }}
143+
144+
- name: Run CommunityToolkit.Maui.UnitTests
145+
run: dotnet test -c Release ${{ env.PathToLibrarySolution }} --settings ".runsettings" --collect "XPlat code coverage" --logger trx --results-directory ${{ runner.temp }}
146+
147+
- name: Publish Test Results
148+
if: runner.os == 'Windows'
149+
uses: actions/upload-artifact@v4
150+
with:
151+
name: Test Results
152+
path: |
153+
${{ runner.temp }}/**/*.trx
154+
155+
- name: Pack CommunityToolkit.Maui.Core NuGet
156+
run: dotnet pack -c Release ${{ env.PathToCommunityToolkitCoreCsproj }} -p:PackageVersion=${{ env.NugetPackageVersion }}
157+
158+
- name: Pack CommunityToolkit.Maui NuGet
159+
run: dotnet pack -c Release ${{ env.PathToCommunityToolkitCsproj }} -p:PackageVersion=${{ env.NugetPackageVersion }}
160+
161+
- name: Pack CommunityToolkit.Maui.Camera NuGet
162+
run: dotnet pack -c Release ${{ env.PathToCommunityToolkitCameraCsproj }} -p:PackageVersion=${{ env.NugetPackageVersionCamera }}
163+
164+
- name: Pack CommunityToolkit.Maui.MediaElement NuGet
165+
run: dotnet pack -c Release ${{ env.PathToCommunityToolkitMediaElementCsproj }} -p:PackageVersion=${{ env.NugetPackageVersionMediaElement }}
166+
167+
- name: Pack CommunityToolkit.Maui.Maps NuGet
168+
run: dotnet pack -c Release ${{ env.PathToCommunityToolkitMapsCsproj }} -p:PackageVersion=${{ env.NugetPackageVersionMaps }}
169+
170+
- name: Copy NuGet Packages to Staging Directory
171+
if: runner.os == 'Windows' && !startsWith(github.ref, 'refs/tags/')
172+
run: |
173+
mkdir -p ${{ github.workspace }}/nuget
174+
Get-ChildItem -Path "./src" -Recurse | Where-Object { $_.Extension -match "nupkg" } | Copy-Item -Destination "${{ github.workspace }}/nuget"
175+
shell: pwsh
176+
177+
- name: Publish Packages
178+
if: runner.os == 'Windows'
179+
uses: actions/upload-artifact@v4
180+
with:
181+
name: Packages
182+
path: ${{ github.workspace }}/nuget/

0 commit comments

Comments
 (0)