-
-
Notifications
You must be signed in to change notification settings - Fork 259
360 lines (345 loc) · 13.9 KB
/
build.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
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
on:
push:
branches:
- main
tags:
- v*
- cli-v*
pull_request:
env:
Configuration: Release
TreatWarningsAsErrors: true
WarningsNotAsErrors: 1573,1591,NU5128
Deterministic: true
RunCodeAnalysis: false
jobs:
pre_build:
runs-on: ubuntu-24.04
outputs:
version: ${{ steps.version.outputs.version }}
version3: ${{ steps.version.outputs.version3 }}
cliVersion: ${{ steps.cliVersion.outputs.version }}
defaults:
run:
working-directory: src
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- run: dotnet tool install -g GitVersion.Tool --version 5.11.1
- name: Resolve version
id: version
run: |
dotnet-gitversion
dotnet-gitversion > version.json
version="$(jq -r '.SemVer' version.json)"
version3="$(jq -r '.MajorMinorPatch' version.json)"
pr_version="$(jq -r '.MajorMinorPatch' version.json)-$(jq -r '.PreReleaseLabel' version.json).${{ github.run_number }}.${{ github.run_attempt }}"
if [ "${{ github.event_name }}" = "pull_request" ]; then version=$pr_version; fi
echo "Resolved version: $version"
echo "version=${version}" >> $GITHUB_OUTPUT
echo "Resolved version3: $version3"
echo "version3=${version3}" >> $GITHUB_OUTPUT
- name: Resolve CLI version
id: cliVersion
run: |
dotnet-gitversion /overrideconfig tag-prefix=cli-v > version.json
version="$(jq -r '.SemVer' version.json)"
pr_version="$(jq -r '.MajorMinorPatch' version.json)-$(jq -r '.PreReleaseLabel' version.json).${{ github.run_number }}.${{ github.run_attempt }}"
if [ "${{ github.event_name }}" = "pull_request" ]; then version=$pr_version; fi
echo "Resolved CLI version: $version"
echo "version=${version}" >> $GITHUB_OUTPUT
- run: dotnet restore Roslynator.sln
- run: dotnet build Roslynator.sln --no-restore
- run: |
dotnet format Roslynator.sln --no-restore --verify-no-changes --severity info
- run: dotnet test Roslynator.sln --no-build
- uses: actions/checkout@v4
with:
repository: josefpihrt/wordb
path: wordb
- run: dotnet tool install -g Roslynator.DotNet.Cli --version 0.8.3
- run: |
roslynator spellcheck Roslynator.sln --dry-run --scope all --words \
spellcheck \
../wordb/data/en \
../wordb/data/en-us \
../wordb/data/names.txt \
../wordb/data/tech.names.txt \
../wordb/data/tech.acronyms.txt
build_core_and_testing:
if: github.ref_type != 'tag' || startsWith(github.ref_name, 'v')
needs: pre_build
runs-on: ubuntu-24.04
env:
Version: ${{ needs.pre_build.outputs.version }}
defaults:
run:
working-directory: src
steps:
- uses: actions/checkout@v4
- run: dotnet restore Roslynator.CoreAndTesting.slnf
- run: dotnet build Roslynator.CoreAndTesting.slnf --no-restore
- run: dotnet pack Roslynator.CoreAndTesting.slnf --no-build -o _nupkg
- uses: actions/upload-artifact@v4
with:
name: nuget_core_and_testing
path: src/_nupkg/*nupkg
build_analyzers:
if: github.ref_type != 'tag' || startsWith(github.ref_name, 'v')
needs: pre_build
runs-on: ubuntu-24.04
env:
Version: ${{ needs.pre_build.outputs.version }}
strategy:
matrix:
component:
- id: analyzers
name: Analyzers
propertyName: Analyzers
- id: formatting_analyzers
name: Formatting.Analyzers
propertyName: FormattingAnalyzers
- id: code_analysis_analyzers
name: CodeAnalysis.Analyzers
propertyName: CodeAnalysisAnalyzers
defaults:
run:
working-directory: src/${{ matrix.component.name }}.CodeFixes
steps:
- uses: actions/checkout@v4
- run: dotnet restore --force /p:RoslynVersion=roslyn3.8
- run: dotnet build --no-restore /p:Roslynator${{ matrix.component.propertyName }}NuGet=true /p:RoslynVersion=roslyn3.8
- run: dotnet restore --force /p:RoslynVersion=roslyn4.7
- run: dotnet build --no-restore /p:Roslynator${{ matrix.component.propertyName }}NuGet=true /p:RoslynVersion=roslyn4.7
- run: dotnet pack --no-build
- uses: actions/upload-artifact@v4
with:
name: nuget_${{ matrix.component.id }}
path: src/${{ matrix.component.name }}.CodeFixes/bin/Release/*.*nupkg
build_refactorings:
if: github.ref_type != 'tag' || startsWith(github.ref_name, 'v')
needs: pre_build
runs-on: ubuntu-24.04
env:
Version: ${{ needs.pre_build.outputs.version }}
defaults:
run:
working-directory: src/Refactorings
steps:
- uses: actions/checkout@v4
- run: dotnet restore --force /p:RoslynVersion=roslyn3.8
- run: dotnet build --no-restore /p:RoslynatorRefactoringsNuGet=true /p:RoslynVersion=roslyn3.8
- run: dotnet restore --force /p:RoslynVersion=roslyn4.7
- run: dotnet build --no-restore /p:RoslynatorRefactoringsNuGet=true /p:RoslynVersion=roslyn4.7
- run: dotnet pack --no-build
- uses: actions/upload-artifact@v4
with:
name: nuget_refactorings
path: src/Refactorings/bin/Release/*.*nupkg
build_code_fixes:
if: github.ref_type != 'tag' || startsWith(github.ref_name, 'v')
needs: pre_build
runs-on: ubuntu-24.04
env:
Version: ${{ needs.pre_build.outputs.version }}
defaults:
run:
working-directory: src/CodeFixes
steps:
- uses: actions/checkout@v4
- run: dotnet restore --force /p:RoslynVersion=roslyn3.8
- run: dotnet build --no-restore /p:RoslynatorCodeFixesNuGet=true /p:RoslynVersion=roslyn3.8
- run: dotnet restore --force /p:RoslynVersion=roslyn4.7
- run: dotnet build --no-restore /p:RoslynatorCodeFixesNuGet=true /p:RoslynVersion=roslyn4.7
- run: dotnet pack --no-build
- uses: actions/upload-artifact@v4
with:
name: nuget_code_fixes
path: src/CodeFixes/bin/Release/*.*nupkg
build_vs_extension:
if: github.ref_type != 'tag' || startsWith(github.ref_name, 'v')
needs: pre_build
runs-on: windows-latest
env:
Version: ${{ needs.pre_build.outputs.version }}
DeployExtension: false
defaults:
run:
working-directory: src/VisualStudio
steps:
- uses: actions/checkout@v4
- run: (Get-Content source.extension.vsixmanifest) -replace 'Version="1.0.0"', 'Version="${{ needs.pre_build.outputs.version3 }}"' | Set-Content source.extension.vsixmanifest
- run: dotnet restore
- uses: microsoft/setup-msbuild@v2
- run: msbuild -m
- uses: actions/upload-artifact@v4
with:
name: vs_extension_vsix
path: src/VisualStudio/bin/Release/net472/*.vsix
- uses: actions/upload-artifact@v4
with:
name: vs_extension_manifest
path: src/VisualStudio/manifest.json
- uses: actions/upload-artifact@v4
with:
name: vs_extension_overview
path: src/VisualStudio/Overview.md
- uses: actions/upload-artifact/merge@v4
with:
name: vs_extension
pattern: vs_extension_*
delete-merged: true
build_vs_code_extension:
if: github.ref_type != 'tag' || startsWith(github.ref_name, 'v')
needs: [ pre_build, build_analyzers ]
runs-on: ubuntu-24.04
env:
Version: ${{ needs.pre_build.outputs.version }}
defaults:
run:
working-directory: src/VisualStudioCode
steps:
- uses: actions/checkout@v4
- run: dotnet restore
- run: dotnet build --no-restore
- run: |
mkdir package/roslyn/analyzers
mkdir package/roslyn/refactorings
mkdir package/roslyn/fixes
cp bin/Release/netstandard2.0/Roslynator.Core.dll package/roslyn/common
cp bin/Release/netstandard2.0/Roslynator.Common.dll package/roslyn/common
cp bin/Release/netstandard2.0/Roslynator.CSharp.dll package/roslyn/common
cp bin/Release/netstandard2.0/Roslynator.Workspaces.Core.dll package/roslyn/common
cp bin/Release/netstandard2.0/Roslynator.Workspaces.Common.dll package/roslyn/common
cp bin/Release/netstandard2.0/Roslynator.CSharp.Workspaces.dll package/roslyn/common
cp bin/Release/netstandard2.0/Roslynator.CSharp.Analyzers.dll package/roslyn/analyzers
cp bin/Release/netstandard2.0/Roslynator.CSharp.Analyzers.CodeFixes.dll package/roslyn/analyzers
cp bin/Release/netstandard2.0/Roslynator.Formatting.Analyzers.dll package/roslyn/analyzers
cp bin/Release/netstandard2.0/Roslynator.Formatting.Analyzers.CodeFixes.dll package/roslyn/analyzers
cp bin/Release/netstandard2.0/Roslynator.CSharp.Refactorings.dll package/roslyn/refactorings
cp bin/Release/netstandard2.0/Roslynator.CSharp.CodeFixes.dll package/roslyn/fixes
name: Copy DLLs to package
- run: >
sed -i 's/"version": "1.0.0"/"version": "${{ needs.pre_build.outputs.version3 }}"/' package/package.json
- run: npm install
working-directory: src/VisualStudioCode/package
- run: npm install -g @vscode/vsce
- run: vsce package
working-directory: src/VisualStudioCode/package
- uses: actions/upload-artifact@v4
with:
name: vs_code_extension
path: src/VisualStudioCode/package/*.vsix
- run: rm package/*.vsix
- run: sed -i s/ms-dotnettools.csharp/muhammad-sammy.csharp/ package/package.json
- run: vsce package
working-directory: src/VisualStudioCode/package
- uses: actions/upload-artifact@v4
with:
name: ovsx_extension
path: src/VisualStudioCode/package/*.vsix
build_core_cli:
if: github.ref_type != 'tag' || startsWith(github.ref_name, 'cli-v')
needs: pre_build
runs-on: ubuntu-24.04
env:
RoslynatorDotNetCli: true
RoslynatorCliVersion: ${{ needs.pre_build.outputs.cliVersion }}
Version: ${{ needs.pre_build.outputs.version }}
defaults:
run:
working-directory: src/CommandLine
steps:
- uses: actions/checkout@v4
- run: dotnet restore
- run: dotnet build --no-restore
- run: dotnet pack --no-build
- uses: actions/upload-artifact@v4
with:
name: nuget_core_cli
path: src/CommandLine/bin/Release/*.*nupkg
build_framework_cli:
if: github.ref_type != 'tag' || startsWith(github.ref_name, 'cli-v')
needs: pre_build
runs-on: windows-latest
env:
RoslynatorCommandLine: true
RoslynatorCliVersion: ${{ needs.pre_build.outputs.cliVersion }}
Version: ${{ needs.pre_build.outputs.version }}
defaults:
run:
working-directory: src/CommandLine
steps:
- uses: actions/checkout@v4
- run: dotnet restore
- run: dotnet build --no-restore
- run: dotnet publish --no-build
- run: dotnet pack --no-build
- uses: actions/upload-artifact@v4
with:
name: nuget_framework_cli
path: src/CommandLine/bin/Release/*.*nupkg
publish_nuget_packages:
needs: [ build_core_and_testing, build_analyzers, build_refactorings, build_code_fixes ]
runs-on: ubuntu-24.04
if: github.ref_type == 'tag' && startsWith(github.ref_name, 'v')
steps:
- uses: actions/download-artifact@v4
with:
pattern: nuget_*
path: nuget
merge-multiple: true
- run: dotnet nuget push "*.nupkg" -k ${{ secrets.NUGET_API_KEY }} -s "https://api.nuget.org/v3/index.json" --skip-duplicate
working-directory: nuget
publish_cli_nuget_packages:
needs: [ build_core_cli, build_framework_cli ]
runs-on: ubuntu-24.04
if: github.ref_type == 'tag' && startsWith(github.ref_name, 'cli-v')
steps:
- uses: actions/download-artifact@v4
with:
pattern: nuget_*
path: nuget
merge-multiple: true
- run: dotnet nuget push "*.nupkg" -k ${{ secrets.NUGET_API_KEY }} -s "https://api.nuget.org/v3/index.json" --skip-duplicate
working-directory: nuget
publish_vs_code_extension:
needs: [ pre_build, build_vs_extension ]
runs-on: ubuntu-24.04
if: github.ref_type == 'tag' && startsWith(github.ref_name, 'v')
steps:
- uses: actions/download-artifact@v4
with:
name: vs_code_extension
path: vs_code_extension
- run: npm install -g @vscode/vsce
- run: vsce publish -p ${{ secrets.VS_MARKETPLACE_TOKEN }} -i "roslynator-${{ needs.pre_build.outputs.version3 }}.vsix"
working-directory: vs_code_extension
publish_ovsx_extension:
needs: [ pre_build, build_vs_code_extension ]
runs-on: ubuntu-24.04
if: github.ref_type == 'tag' && startsWith(github.ref_name, 'v')
steps:
- uses: actions/download-artifact@v4
with:
name: ovsx_extension
path: ovsx_extension
- run: npm install -g ovsx
- run: ovsx publish -p ${{ secrets.OPEN_VSX_TOKEN }} -i "roslynator-${{ needs.pre_build.outputs.version3 }}.vsix"
working-directory: ovsx_extension
publish_vs_extension:
needs: build_vs_extension
runs-on: windows-latest
if: github.ref_type == 'tag' && startsWith(github.ref_name, 'v')
steps:
- uses: actions/download-artifact@v4
with:
name: vs_extension
path: vs_extension
- run: |
$visualStudioPath = vswhere -latest -products * -requires Microsoft.VisualStudio.Component.VSSDK -property installationPath
$vsixPublisher = Join-Path "$visualStudioPath" "VSSDK\VisualStudioIntegration\Tools\Bin\VsixPublisher.exe"
& "$vsixPublisher" publish -payload Roslynator.VisualStudio.vsix -publishManifest manifest.json -personalAccessToken ${{ secrets.VS_MARKETPLACE_TOKEN }}
working-directory: vs_extension
name: Publish VS extension to Marketplace