Skip to content

Commit d4a2700

Browse files
authored
Merge pull request #1105 from CommunityToolkit/dev/gh-actions-migration
Migrate workflow to GitHub Actions
2 parents 657c697 + 69a5aa4 commit d4a2700

File tree

4 files changed

+183
-74
lines changed

4 files changed

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

.github/workflows/ci-build.yml

Lines changed: 181 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,181 @@
1+
name: CI-build
2+
3+
# This workflow should trigger in the following cases:
4+
# - The commit is any push in any branch in the repo
5+
# - The commit is a published PR from anyone else
6+
#
7+
# This setup is done to avoid duplicate runs for the same exact commits, for cases when
8+
# the PR is done from a branch in this repo, which would already trigger the "push"
9+
# condition. This way, only PRs from forks will actually trigger the workflow.
10+
#
11+
# Because we can't really check these conditions from the global triggers here, they are
12+
# added to the two root jobs below instead. If canceled, the whole workflow will stop.
13+
on: [push, pull_request]
14+
15+
env:
16+
IS_MAIN: ${{ github.ref == 'refs/heads/main' }}
17+
IS_PR: ${{ startsWith(github.ref, 'refs/pull/') }}
18+
IS_RELEASE: ${{ startsWith(github.ref, 'refs/heads/rel/') }}
19+
20+
jobs:
21+
22+
# Build the solution, run all tests, push packages to the PR feed
23+
build-and-test:
24+
if: >-
25+
github.event_name == 'push' ||
26+
github.event.pull_request.user.login != github.repository_owner
27+
strategy:
28+
matrix:
29+
configuration: [Debug, Release]
30+
runs-on: windows-2022
31+
steps:
32+
- name: Git checkout
33+
uses: actions/checkout@v5
34+
35+
- name: Install .NET SDK
36+
uses: actions/setup-dotnet@v5
37+
with:
38+
global-json-file: global.json
39+
40+
# Build the whole solution
41+
- name: Build solution
42+
run: dotnet build -c ${{matrix.configuration}} /bl
43+
- name: Upload MSBuild binary log
44+
uses: actions/upload-artifact@v5
45+
with:
46+
name: msbuild_log_${{matrix.configuration}}
47+
path: msbuild.binlog
48+
if-no-files-found: error
49+
50+
# Run tests
51+
- name: Test solution
52+
run: dotnet test --no--build -c ${{matrix.configuration}} -l "trx;LogFileName=VSTestResults.trx"
53+
54+
# Publish test results
55+
- name: Publish test results
56+
uses: actions/upload-artifact@v5
57+
with:
58+
name: '**/TestResults/VSTestResults.trx'
59+
path: VSTestResults
60+
if-no-files-found: error
61+
62+
# Pack solution
63+
- name: Pack solution
64+
run: dotnet pack --no-build -c ${{matrix.configuration}}
65+
66+
# Push PR packages to our DevOps artifacts feed (see nuget.config)
67+
- name: Push PR packages (if not fork)
68+
if: ${{ env.IS_PR == 'true' && matrix.configuration == 'Release' && github.event.pull_request.head.repo.full_name == github.repository && github.actor != 'dependabot[bot]' }}
69+
run: |
70+
dotnet nuget add source https://pkgs.dev.azure.com/dotnet/CommunityToolkit/_packaging/CommunityToolkit-PullRequests/nuget/v3/index.json `
71+
--name PullRequests `
72+
--username dummy --password ${{ secrets.DEVOPS_PACKAGE_PUSH_TOKEN }}
73+
dotnet nuget push "*.nupkg" --api-key dummy --source PullRequests --skip-duplicate
74+
75+
- name: Upload packages list
76+
uses: actions/upload-artifact@v5
77+
if: ${{ env.IS_PR == 'false' && matrix.configuration == 'Release' }}
78+
with:
79+
name: nuget-list-dotnet
80+
if-no-files-found: error
81+
path: |
82+
${{ github.workspace }}/.github/workflows/SignClientFileList.txt
83+
84+
# If we're not doing a PR build (or it's a PR from a fork) then we upload our packages so we can sign as a separate job or have available to test
85+
- name: Upload packages artifacts
86+
uses: actions/upload-artifact@v5
87+
if: ${{ (env.IS_PR == 'false' || github.event.pull_request.head.repo.full_name != github.repository) && matrix.configuration == 'Release' }}
88+
with:
89+
name: nuget-packages-dotnet
90+
if-no-files-found: error
91+
path: |
92+
./*.nupkg
93+
94+
# Sign the packages for release
95+
sign:
96+
needs: [build-and-test]
97+
if: ${{ env.IS_MAIN == 'true' || env.Is_RELEASE == 'true' }}
98+
runs-on: windows-latest
99+
permissions:
100+
id-token: write # Required for requesting the JWT
101+
102+
steps:
103+
- name: Install .NET SDK
104+
uses: actions/setup-dotnet@v5
105+
with:
106+
global-json-file: global.json
107+
108+
- name: Download packages list
109+
uses: actions/download-artifact@v5
110+
with:
111+
name: nuget-list-dotnet
112+
path: ./
113+
114+
- name: Download built packages for .NCT
115+
uses: actions/download-artifact@v5
116+
with:
117+
name: nuget-packages-dotnet
118+
path: ./packages
119+
120+
- name: Install Signing Tool
121+
run: dotnet tool install --tool-path ./tools sign --version 0.9.1-beta.25379.1
122+
123+
- name: Sign packages
124+
run: >
125+
./tools/sign code azure-key-vault
126+
**/*.nupkg
127+
--base-directory "${{ github.workspace }}/packages"
128+
--file-list "${{ github.workspace }}/SignClientFileList.txt"
129+
--timestamp-url "http://timestamp.digicert.com"
130+
--publisher-name ".NET Foundation"
131+
--description ".NET Community Toolkit"
132+
--description-url "https://github.com/CommunityToolkit/dotnet"
133+
--azure-key-vault-url "${{ secrets.SIGN_KEY_VAULT_URL }}"
134+
--azure-key-vault-client-id ${{ secrets.SIGN_CLIENT_ID }}
135+
--azure-key-vault-client-secret "${{ secrets.SIGN_CLIENT_SECRET }}"
136+
--azure-key-vault-tenant-id ${{ secrets.SIGN_TENANT_ID }}
137+
--azure-key-vault-certificate "${{ secrets.SIGN_CERTIFICATE }}"
138+
--verbosity Information
139+
140+
- name: Push signed packages
141+
run: |
142+
dotnet nuget add source https://pkgs.dev.azure.com/dotnet/CommunityToolkit/_packaging/CommunityToolkit-MainLatest/nuget/v3/index.json `
143+
--name MainLatest `
144+
--username dummy --password ${{ secrets.DEVOPS_PACKAGE_PUSH_TOKEN }}
145+
dotnet nuget push "**/*.nupkg" --api-key dummy --source MainLatest --skip-duplicate
146+
147+
- name: Upload signed packages as artifacts (for release)
148+
uses: actions/upload-artifact@v5
149+
if: ${{ env.IS_RELEASE == 'true' }}
150+
with:
151+
name: signed-nuget-packages-dotnet
152+
if-no-files-found: error
153+
path: |
154+
${{ github.workspace }}/packages/**/*.nupkg
155+
156+
# Push official packages to NuGet
157+
release:
158+
if: ${{ env.IS_RELEASE == 'true' }}
159+
needs: [sign]
160+
environment: nuget-release-gate # This gates this job until manually approved
161+
runs-on: ubuntu-latest
162+
163+
steps:
164+
- name: Install .NET SDK
165+
uses: actions/setup-dotnet@v5
166+
with:
167+
global-json-file: global.json
168+
169+
- name: Download signed packages for .NCT
170+
uses: actions/download-artifact@v5
171+
with:
172+
name: signed-nuget-packages-dotnet
173+
path: ./packages
174+
175+
- name: Push to NuGet.org
176+
run: >
177+
dotnet nuget push
178+
**/*.nupkg
179+
--source https://api.nuget.org/v3/index.json
180+
--api-key ${{ secrets.NUGET_PACKAGE_PUSH_TOKEN }}
181+
--skip-duplicate

azure-pipelines.yml

Lines changed: 0 additions & 73 deletions
This file was deleted.

global.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"sdk": {
3-
"version": "9.0.100",
3+
"version": "9.0.301",
44
"rollForward": "latestFeature",
55
"allowPrerelease": false
66
}

0 commit comments

Comments
 (0)