Repository navigation
153 lines (130 loc) · 4.99 KB
/
Copy pathbuild.yml
File metadata and controls
153 lines (130 loc) · 4.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
name: Build
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
env:
DOTNET_NOLOGO: true
DOTNET_CLI_TELEMETRY_OPTOUT: true
jobs:
discover:
name: Discover samples
runs-on: ubuntu-latest
outputs:
dotnet: ${{ steps.discover.outputs.dotnet }}
node: ${{ steps.discover.outputs.node }}
steps:
- name: Checkout repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
# On pull requests HEAD is the merge commit; its first parent is the base branch.
fetch-depth: ${{ github.event_name == 'pull_request' && 2 || 1 }}
- name: Setup .NET
uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # v6.0.0
with:
global-json-file: global.json
# Pull requests build only the samples affected by the change; pushes and manual runs build everything.
- name: List changed files
if: github.event_name == 'pull_request'
run: |
git diff --name-only --no-renames HEAD^1 HEAD > "$RUNNER_TEMP/changed-files.txt"
echo "CHANGED_FILES=$RUNNER_TEMP/changed-files.txt" >> "$GITHUB_ENV"
cat "$RUNNER_TEMP/changed-files.txt"
- name: Discover solutions and npm projects
id: discover
run: dotnet run .github/scripts/discover-builds.cs
dotnet:
name: ${{ matrix.path }}
needs: discover
if: needs.discover.outputs.dotnet != '[]'
# Windows jobs (MAUI, .NET Framework) run on a 16-core larger runner from the org's "Large" runner group.
runs-on: ${{ matrix.os == 'windows-latest' && fromJSON('{"group":"Large","labels":["windows-latest-x64-16core"]}') || matrix.os }}
strategy:
fail-fast: false
matrix:
include: ${{ fromJson(needs.discover.outputs.dotnet) }}
steps:
- name: Checkout repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Setup .NET
uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # v6.0.0
with:
global-json-file: global.json
- name: Build
if: matrix.kind == 'sdk'
run: dotnet build "${{ matrix.path }}" -c Release
- name: Install MAUI workload
if: matrix.kind == 'maui'
run: dotnet workload install maui
- name: Build (MAUI)
if: matrix.kind == 'maui'
run: dotnet build "${{ matrix.path }}" -c Release -f "${{ matrix.framework }}"
- name: Setup MSBuild
if: matrix.kind == 'netfx'
uses: microsoft/setup-msbuild@30375c66a4eea26614e0d39710365f22f8b0af57 # v3
- name: Setup NuGet
if: matrix.kind == 'netfx'
uses: NuGet/setup-nuget@fd55a6f3b34392fa83fde1454582407d8c714123 # v4.0
- name: Build (.NET Framework)
if: matrix.kind == 'netfx'
run: |
nuget restore "${{ matrix.path }}"
msbuild "${{ matrix.path }}" -p:Configuration=Release -m
node:
name: ${{ matrix.path }}
needs: discover
if: needs.discover.outputs.node != '[]'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include: ${{ fromJson(needs.discover.outputs.node) }}
defaults:
run:
working-directory: ${{ matrix.path }}
steps:
- name: Checkout repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Setup Node.js
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: 22
cache: npm
cache-dependency-path: ${{ matrix.path }}/package-lock.json
# The Vite configs export an ASP.NET Core dev certificate via `dotnet dev-certs` when loaded.
- name: Setup .NET
uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # v6.0.0
with:
global-json-file: global.json
- name: Prepare dev certificate folders
run: mkdir -p "$HOME/.aspnet/https" "$HOME/.aspnet/dev-certs/https"
- name: Install dependencies
run: npm ci
- name: Build
run: npm run build
build-result:
name: Build result
needs: [ discover, dotnet, node ]
if: always()
runs-on: ubuntu-latest
steps:
# dotnet/node are skipped when a pull request affects none of their samples.
- name: Check build results
env:
DISCOVER_RESULT: ${{ needs.discover.result }}
DOTNET_RESULT: ${{ needs.dotnet.result }}
NODE_RESULT: ${{ needs.node.result }}
run: |
echo "discover: $DISCOVER_RESULT"
echo "dotnet: $DOTNET_RESULT"
echo "node: $NODE_RESULT"
[[ "$DISCOVER_RESULT" == "success" ]] &&
[[ "$DOTNET_RESULT" == "success" || "$DOTNET_RESULT" == "skipped" ]] &&
[[ "$NODE_RESULT" == "success" || "$NODE_RESULT" == "skipped" ]]