-
Notifications
You must be signed in to change notification settings - Fork 236
175 lines (154 loc) · 5.95 KB
/
dotnet.yml
File metadata and controls
175 lines (154 loc) · 5.95 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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
name: Build CodeConverter
on:
push:
branches: [ master, main ]
pull_request:
branches: [ master, main ]
workflow_dispatch:
inputs:
publishNuget:
description: "Publish NuGet package and dotnet tool"
required: false
type: boolean
default: false
deployWebFunc:
description: "Deploy web/func artifacts"
required: false
type: boolean
default: false
createRelease:
description: "Create GitHub release"
required: false
type: boolean
default: false
nugetApiKey:
description: "NuGet API key (required if Publish NuGet is checked)"
required: false
type: string
env:
BuildVersion: '10.0.0'
jobs:
build:
runs-on: windows-2022
env:
BuildPlatform: Any CPU
BuildTarget: Release
steps:
- uses: actions/checkout@v4
- name: Update project version
uses: roryprimrose/set-vs-sdk-project-version@v1.0.6
with:
projectFilter: 'Directory.Build.props'
version: ${{ env.BuildVersion }}.${{ github.run_number }}
assemblyVersion: ${{ env.BuildVersion }}.${{ github.run_number }}
fileVersion: ${{ env.BuildVersion }}.${{ github.run_number }}
- name: Setup .NET for main build
uses: actions/setup-dotnet@v4
with:
dotnet-version: 10.0.x
- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v2
with:
vs-version: '[17.0,)'
- name: Dotnet deterministic Build
run: dotnet build DotNetBuildable.slnf /p:Platform=$env:BuildPlatform /p:Configuration=$env:BuildTarget /p:ContinuousIntegrationBuild=true
- name: Dotnet Publish
run: dotnet publish DotNetPublishable.slnf /p:Platform=$env:BuildPlatform /p:Configuration=$env:BuildTarget
- name: MSBuild Vsix
run: msbuild Vsix\Vsix.csproj -restore /p:Configuration=$env:BuildTarget
- name: Execute unit tests
run: dotnet test $env:Tests1
env:
Tests1: Tests/bin/${{ env.BuildTarget }}/ICSharpCode.CodeConverter.Tests.dll
- name: Run vitest
working-directory: Web
run: npm test -- --run
- name: Upload NuGet package
uses: actions/upload-artifact@v4
with:
name: ICSharpCode.CodeConverter.${{ env.BuildVersion }}.nupkg
path: CodeConverter/bin/${{ env.BuildTarget }}/ICSharpCode.CodeConverter.*.nupkg
- name: Upload VSIX
uses: actions/upload-artifact@v4
with:
name: ICSharpCode.CodeConverter.VsExtension.${{ env.BuildVersion }}.vsix
path: Vsix/bin/${{ env.BuildTarget }}/ICSharpCode.CodeConverter.VsExtension.vsix
- name: Upload Tool
uses: actions/upload-artifact@v4
with:
name: ICSharpCode.CodeConverter.CodeConv.${{ env.BuildVersion }}.nupkg
path: CodeConv/bin/${{ env.BuildTarget }}/ICSharpCode.CodeConverter.CodeConv.*.nupkg
- name: Upload Web
uses: actions/upload-artifact@v4
with:
name: ICSharpCode.CodeConverter.Web.${{ env.BuildVersion }}.zip
path: web/dist/
- name: Upload Function
uses: actions/upload-artifact@v4
with:
name: ICSharpCode.CodeConverter.Func.${{ env.BuildVersion }}.zip
path: Func/bin/${{ env.BuildTarget }}/publish/
deploy:
if: ${{ github.event_name == 'workflow_dispatch' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main') }}
concurrency: ci-${{ github.ref }}
needs: [build] # The second job must depend on the first one to complete before running and uses ubuntu-latest instead of windows.
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout 🛎️
uses: actions/checkout@v4
- name: Download web artifact 🔻 # The built project is downloaded into the 'site' folder.
if: ${{ inputs.deployWebFunc }}
uses: actions/download-artifact@v4
with:
name: ICSharpCode.CodeConverter.Web.${{ env.BuildVersion }}.zip
path: site
- name: Download release artifacts
if: ${{ inputs.createRelease || inputs.publishNuget }}
uses: actions/download-artifact@v4
with:
pattern: ICSharpCode.CodeConverter.*
path: release-artifacts
merge-multiple: true
- name: Extract latest changelog section
id: changelog
shell: pwsh
if: ${{ inputs.createRelease }}
run: |
./Get-LatestChangelog.ps1 -Path CHANGELOG.md | Tee-Object -FilePath release-notes.md
"notes<<EOF" >> $env:GITHUB_OUTPUT
Get-Content release-notes.md >> $env:GITHUB_OUTPUT
"EOF" >> $env:GITHUB_OUTPUT
- name: Deploy 🚀
if: ${{ inputs.deployWebFunc }}
uses: JamesIves/github-pages-deploy-action@v4
with:
branch: 'autoupdated/gh-pages'
folder: 'site/wwwroot'
- name: Publish NuGet packages
if: ${{ inputs.publishNuget }}
shell: pwsh
env:
NUGET_API_KEY: ${{ inputs.nugetApiKey }}
run: |
if (-not $env:NUGET_API_KEY) { throw "nugetApiKey input is required when Publish NuGet is checked." }
Write-Output "::add-mask::$env:NUGET_API_KEY"
$source = "https://api.nuget.org/v3/index.json"
$packages = @(
"release-artifacts/ICSharpCode.CodeConverter.*.nupkg",
"release-artifacts/ICSharpCode.CodeConverter.CodeConv.*.nupkg"
)
foreach ($pattern in $packages) {
Get-ChildItem -Path $pattern -File | ForEach-Object {
dotnet nuget push $_.FullName -k $env:NUGET_API_KEY -s $source --skip-duplicate
}
}
- name: Create GitHub release
if: ${{ inputs.createRelease }}
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ env.BuildVersion }}.${{ github.run_number }}
name: v${{ env.BuildVersion }}.${{ github.run_number }}
body: ${{ steps.changelog.outputs.notes }}
files: release-artifacts/**