-
Notifications
You must be signed in to change notification settings - Fork 33
191 lines (170 loc) · 5.84 KB
/
main.yml
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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
on:
push:
branches:
- main
release:
types:
- published
pull_request:
name: pipeline
env:
DOTNET_CLI_TELEMETRY_OPTOUT: true
DOTNET_NOLOGO: true
dotnet-version: |
8.0.x
7.0.x
6.0.x
jobs:
determine-version:
runs-on: ubuntu-latest
env:
IGNORE_NORMALISATION_GIT_HEAD_MOVE: 1
# v5.10.0 of GitVersion has a fix for incorrect versions when building on tag. See https://github.com/GitTools/GitVersion/issues/2838
# It appears that the fix then had a regression in a later version, so pinning to v5.10.0. See https://github.com/GitTools/GitVersion/issues/3351#issuecomment-1403657689
GITVERSION: '5.10.0'
outputs:
version: ${{ steps.gitversion.outputs.fullSemVer }}
package-version: ${{ steps.gitversion.outputs.fullSemVer }}
assembly-version: ${{ steps.gitversion.outputs.assemblySemVer }}
file-version: ${{ steps.gitversion.outputs.assemblySemFileVer }}
informational-version: ${{ steps.gitversion.outputs.informationalVersion }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- name: Install GitVersion ${{ env.GITVERSION }}
uses: gittools/actions/gitversion/[email protected]
with:
versionSpec: ${{ env.GITVERSION }}
- name: Determine version
uses: gittools/actions/gitversion/[email protected]
id: gitversion
with:
useConfigFile: true
build:
needs:
- determine-version
name: build (v${{ needs.determine-version.outputs.version }})
runs-on: ubuntu-latest
env:
msbuild-version-args: /p:Version="${{ needs.determine-version.outputs.version }}" /p:PackageVersion="${{ needs.determine-version.outputs.package-version }}" /p:AssemblyVersion="${{ needs.determine-version.outputs.assembly-version }}" /p:FileVersion="${{ needs.determine-version.outputs.file-version }}" /p:InformationalVersion="${{ needs.determine-version.outputs.informational-version }}"
outputs:
dotnet-version: ${{ env.dotnet-version }}
msbuild-version-args: ${{ env.msbuild-version-args }}
steps:
# Setup
- uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.dotnet-version }}
- run: dotnet --info
# Checkout
- uses: actions/checkout@v4
with:
fetch-depth: 1
# NuGet cache
- name: Restore NuGet global package cache
uses: actions/cache@v4
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.targets','**/*.props','**/*.csproj') }} # Can't use packages.lock.json yet, because Dependabot does not support it.
restore-keys: |
${{ runner.os }}-nuget-
# Restore
- run: dotnet restore
# Build
- run: dotnet build --no-restore -c Release ${{ env.msbuild-version-args }}
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: build
path: |
*/**/bin
*/**/obj
if-no-files-found: error
retention-days: 7
test:
needs: build
strategy:
matrix:
os:
- ubuntu-latest
- windows-latest
- macos-13
fail-fast: false
runs-on: ${{ matrix.os }}
steps:
# Setup
- uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.dotnet-version }}
# Checkout
- uses: actions/checkout@v4
with:
fetch-depth: 1
# Restore build artifacts
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: build
# Run all tests
- run: dotnet test --no-restore --no-build -c Release -- xUnit.AppDomain=denied
if: matrix.os == 'ubuntu-latest'
- run: dotnet test --no-restore --no-build -c Release --filter Category!=PublicApi -- xUnit.AppDomain=denied
if: matrix.os != 'ubuntu-latest'
pack:
needs:
- determine-version
- build
runs-on: ubuntu-latest
steps:
# Setup
- uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.dotnet-version }}
# Checkout
- uses: actions/checkout@v4
with:
fetch-depth: 1
# NuGet cache (.NET Framework Reference assemblies are needed for pack)
- name: Restore NuGet global package cache
uses: actions/cache@v4
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.targets','**/*.props','**/*.csproj') }} # Can't use packages.lock.json yet, because Dependabot does not support it.
restore-keys: |
${{ runner.os }}-nuget-
fail-on-cache-miss: true
# Restore build artifacts
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: build
# Pack
- run: dotnet pack --no-restore --no-build -c Release ${{ needs.build.outputs.msbuild-version-args }}
- name: Upload release artifacts
uses: actions/upload-artifact@v4
with:
name: release-${{ needs.determine-version.outputs.package-version }}
path: |
**/*.*nupkg
if-no-files-found: error
retention-days: 90
deploy:
needs:
- determine-version
- test
- pack
if: github.event_name == 'release'
environment: production
runs-on: ubuntu-latest
steps:
# Restore release artifacts
- name: Download release artifact
uses: actions/download-artifact@v4
with:
name: release-${{ needs.determine-version.outputs.package-version }}
- name: push - nuget.org
env:
NUGET_SOURCE_URL: https://api.nuget.org/v3/index.json
run: dotnet nuget push **/*.nupkg -k ${{ secrets.NUGET_API_KEY }} -s ${{ env.NUGET_SOURCE_URL }}