-
Notifications
You must be signed in to change notification settings - Fork 416
160 lines (144 loc) · 4.69 KB
/
Copy pathci.yml
File metadata and controls
160 lines (144 loc) · 4.69 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
154
155
156
157
158
159
160
name: CI Build
on:
push:
branches:
- master
- 'release/**'
- 'maintenance/**'
paths-ignore:
- '**/*.md'
- '**/*.png'
workflow_dispatch:
inputs:
run_tests:
description: Run tests
required: true
default: true
type: boolean
collect_coverage:
description: Collect and upload coverage (requires tests)
required: true
default: true
type: boolean
pack_nugets:
description: Pack and upload NuGet artifacts
required: true
default: true
type: boolean
upload_artifacts:
description: Create and upload the full artifact archive
required: true
default: true
type: boolean
publish_nuget:
description: Publish to nuget.org (master only; forces packing)
required: true
default: false
type: boolean
permissions:
contents: read
concurrency:
group: ci-${{ github.workflow }}-${{ github.ref }}
# Never interrupt a master run while it may be publishing an immutable package set.
cancel-in-progress: ${{ github.ref != 'refs/heads/master' }}
env:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
DOTNET_CLI_TELEMETRY_OPTOUT: true
jobs:
build-and-test:
name: CI Build & Test
runs-on: ubuntu-latest
timeout-minutes: 30
permissions:
contents: read
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v7
with:
fetch-depth: 1
lfs: true
- name: Setup .NET SDKs
uses: actions/setup-dotnet@v6
with:
dotnet-version: |
8.0.x
9.0.x
10.0.x
- name: Build selected components
shell: pwsh
env:
RUN_TESTS: ${{ github.event_name != 'workflow_dispatch' || inputs.run_tests }}
COLLECT_COVERAGE: ${{ github.event_name != 'workflow_dispatch' || inputs.collect_coverage }}
PACK_NUGETS: ${{ github.event_name != 'workflow_dispatch' || inputs.pack_nugets || inputs.publish_nuget }}
CREATE_ARCHIVE: ${{ github.event_name != 'workflow_dispatch' || inputs.upload_artifacts }}
run: |
$buildArguments = @()
if ($env:RUN_TESTS -ne 'true') { $buildArguments += '-SkipTests' }
if ($env:COLLECT_COVERAGE -ne 'true') { $buildArguments += '-SkipCoverage' }
if ($env:PACK_NUGETS -ne 'true') { $buildArguments += '-SkipPack' }
if ($env:CREATE_ARCHIVE -ne 'true') { $buildArguments += '-SkipArchive' }
./Build/build.ps1 @buildArguments
# Codecov intermittently fails while importing its verification key from Keybase.
# Keep coverage non-blocking until upstream adds reliable retry/error handling:
# https://github.com/codecov/codecov-action/issues/1876
# https://github.com/codecov/wrapper/pull/66
- name: Upload coverage to Codecov
if: github.event_name != 'workflow_dispatch' || (inputs.run_tests && inputs.collect_coverage)
continue-on-error: true
uses: codecov/codecov-action@v6
with:
directory: Artifacts/Coverage
fail_ci_if_error: true
plugins: noop
use_oidc: true
- name: Upload artifacts
if: github.event_name != 'workflow_dispatch' || inputs.upload_artifacts
uses: actions/upload-artifact@v7
with:
name: artifacts
path: Artifacts/
retention-days: 30
- name: Upload NuGet packages
if: github.event_name != 'workflow_dispatch' || inputs.pack_nugets || inputs.publish_nuget
uses: actions/upload-artifact@v7
with:
name: nuget-packages
path: |
Artifacts/**/*.nupkg
Artifacts/**/*.snupkg
if-no-files-found: error
retention-days: 30
publish-nuget:
name: Publish NuGet packages
needs: build-and-test
runs-on: ubuntu-latest
timeout-minutes: 10
if: >-
github.ref == 'refs/heads/master' &&
github.repository_owner == 'angularsen' &&
(github.event_name == 'push' || inputs.publish_nuget)
environment: Publish
permissions:
contents: read
id-token: write
steps:
- name: Download NuGet packages
uses: actions/download-artifact@v8
with:
name: nuget-packages
path: nugets
- name: Setup .NET SDK
uses: actions/setup-dotnet@v6
with:
dotnet-version: 10.0.x
- name: Log in to NuGet with trusted publishing
uses: NuGet/login@v1
id: nuget-login
with:
user: angularsen
- name: Push to nuget.org
env:
NUGET_API_KEY: ${{ steps.nuget-login.outputs.NUGET_API_KEY }}
run: dotnet nuget push "**/*.nupkg" --skip-duplicate --api-key "$NUGET_API_KEY" --source https://api.nuget.org/v3/index.json
working-directory: nugets