Skip to content

Commit 1412e57

Browse files
Use GitHub Actions for CI and release (#2091)
* Use GitHub Actions * Add sign and release * update with latest version * xcode 15.3 * Update dotnet-build.yml * Update dotnet-build.yml * Update azure-pipelines.yml * Disable Azure Pipelines for PRs * Update azure-pipelines.yml --------- Co-authored-by: Gerald Versluis <gerald.versluis@microsoft.com>
1 parent f359148 commit 1412e57

File tree

3 files changed

+284
-13
lines changed

3 files changed

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

.github/workflows/dotnet-build.yml

Lines changed: 270 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,270 @@
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: '9.0.102'
26+
LATEST_NET_VERSION: '9.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: '16.2'
47+
CommunityToolkitLibrary_Xcode_Version: '16.2'
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-15]
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-15]
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: Upload Package List
178+
uses: actions/upload-artifact@v4
179+
if: runner.os == 'Windows'
180+
with:
181+
name: nuget-list
182+
if-no-files-found: error
183+
path: |
184+
${{ github.workspace }}/.github/workflows/SignClientFileList.txt
185+
186+
- name: Publish Packages
187+
if: runner.os == 'Windows'
188+
uses: actions/upload-artifact@v4
189+
with:
190+
name: packages
191+
path: ${{ github.workspace }}/nuget/
192+
193+
sign:
194+
needs: [build_library]
195+
if: ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/rel/') }}
196+
runs-on: windows-latest
197+
permissions:
198+
id-token: write # Required for requesting the JWT
199+
200+
steps:
201+
- name: Install .NET SDK
202+
uses: actions/setup-dotnet@v3
203+
with:
204+
dotnet-version: ${{ env.TOOLKIT_NET_VERSION }}
205+
206+
- name: Download NuGet List
207+
uses: actions/download-artifact@v4
208+
with:
209+
name: nuget-list
210+
path: ./
211+
212+
- name: Download Package List
213+
uses: actions/download-artifact@v4
214+
with:
215+
name: packages
216+
path: ./packages
217+
218+
- name: Install Signing Tool
219+
run: dotnet tool install --tool-path ./tools sign --version 0.9.1-beta.23356.1
220+
221+
- name: Sign Packages
222+
run: >
223+
./tools/sign code azure-key-vault
224+
**/*.nupkg
225+
--base-directory "${{ github.workspace }}/packages"
226+
--file-list "${{ github.workspace }}/SignClientFileList.txt"
227+
--timestamp-url "http://timestamp.digicert.com"
228+
--publisher-name ".NET Foundation"
229+
--description "Community Toolkit MAUI"
230+
--description-url "https://github.com/CommunityToolkit/Maui"
231+
--azure-key-vault-url "${{ secrets.SIGN_KEY_VAULT_URL }}"
232+
--azure-key-vault-client-id ${{ secrets.SIGN_CLIENT_ID }}
233+
--azure-key-vault-client-secret "${{ secrets.SIGN_CLIENT_SECRET }}"
234+
--azure-key-vault-tenant-id ${{ secrets.SIGN_TENANT_ID }}
235+
--azure-key-vault-certificate "${{ secrets.SIGN_CERTIFICATE }}"
236+
--verbosity Information
237+
238+
- name: Publish Packages
239+
uses: actions/upload-artifact@v4
240+
with:
241+
name: signed-packages
242+
if-no-files-found: error
243+
path: |
244+
${{ github.workspace }}/packages/**/*.nupkg
245+
246+
release:
247+
if: ${{ startsWith(github.ref, 'refs/heads/rel/') }}
248+
needs: [sign]
249+
environment: nuget-release-gate # This gates this job until manually approved
250+
runs-on: ubuntu-latest
251+
252+
steps:
253+
- name: Install .NET SDK
254+
uses: actions/setup-dotnet@v3
255+
with:
256+
dotnet-version: ${{ env.TOOLKIT_NET_VERSION }}
257+
258+
- name: Download signed packages for ${{ matrix.platform }}
259+
uses: actions/download-artifact@v4
260+
with:
261+
name: signed-packages
262+
path: ./packages
263+
264+
- name: Push to NuGet.org
265+
run: >
266+
dotnet nuget push
267+
**/*.nupkg
268+
--source https://api.nuget.org/v3/index.json
269+
--api-key ${{ secrets.NUGET_PACKAGE_PUSH_TOKEN }}
270+
--skip-duplicate

azure-pipelines.yml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,26 +32,26 @@ variables:
3232
CommunityToolkitLibrary_Xcode_Version: '16.2'
3333

3434
trigger:
35-
branches:
36-
include:
37-
- main
38-
- develop
35+
# branches:
36+
# include:
37+
# - main
38+
# - develop
3939
tags:
4040
include:
4141
- '*'
4242
paths:
4343
exclude:
4444
- README.md
4545

46-
pr:
47-
autoCancel: 'true'
48-
branches:
49-
include:
50-
- main
51-
- develop
52-
paths:
53-
exclude:
54-
- README.md
46+
# pr:
47+
# autoCancel: 'true'
48+
# branches:
49+
# include:
50+
# - main
51+
# - develop
52+
# paths:
53+
# exclude:
54+
# - README.md
5555

5656
jobs:
5757
- job: build_sample

0 commit comments

Comments
 (0)