-
-
Notifications
You must be signed in to change notification settings - Fork 329
338 lines (324 loc) · 13.7 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
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
name: Build & Release (Azure DevOps Migration Tools)
on:
push:
tags-ignore:
- 'v*-*'
pull_request:
branches:
- main
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
APP_ID: "Iv23li9aYvt0VW9x4Jhh"
PRIVATE_KEY: ${{ secrets.NKDAGILITY_BOT_CLIENTSECRET }}
jobs:
# Setup & Configuration
Setup:
name: "Setup & Configuration"
runs-on: ubuntu-latest
outputs:
GitVersion_BranchName: ${{ steps.gitversion.outputs.GitVersion_BranchName }}
GitVersion_SemVer: ${{ steps.gitversion.outputs.GitVersion_SemVer }}
GitVersion_PreReleaseLabel: ${{ steps.gitversion.outputs.GitVersion_PreReleaseLabel }}
GitVersion_AssemblySemVer: ${{ steps.gitversion.outputs.GitVersion_AssemblySemVer }}
GitVersion_InformationalVersion: ${{ steps.gitversion.outputs.GitVersion_InformationalVersion }}
GitVersion_NuGetVersion: ${{ steps.gitversion.outputs.GitVersion_NuGetVersion }}
Filter_src: ${{ steps.filter.outputs.src }}
Filter_docs: ${{ steps.filter.outputs.docs }}
Filter_automation: ${{ steps.filter.outputs.automation }}
nkdAgility_Ring: ${{ steps.nkdagility-outputs.outputs.Ring }}
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Install GitVersion
uses: gittools/actions/gitversion/[email protected]
with:
versionSpec: '5.x'
includePrerelease: true
- name: Execute GitVersion
id: gitversion
uses: gittools/actions/gitversion/[email protected]
with:
useConfigFile: true
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
src:
- 'src/**'
docs:
- 'docs/**'
automation:
- 'build/**'
- '.github/workflows/**'
- name: "Build NKDAgility Outputs"
shell: pwsh
id: nkdagility-outputs
run: |
$Ring = "Canary"
switch ($Env:GitVersion_PreReleaseLabel) {
"" {
$Ring = "Release";
}
"Preview" {
$Ring = "Preview";
}
default {
$Ring = "Canary";
}
}
Write-Output "We are running for the $Ring Ring!"
echo "Ring=$Ring" >> $env:GITHUB_OUTPUT
# Setup Validator
SetupValidatorStage:
name: "Setup Validator"
runs-on: ubuntu-latest
needs: Setup
steps:
- name: "Release WorkItemClone"
shell: pwsh
run: |
Write-Output "GitVersion_BranchName: ${{needs.Setup.outputs.GitVersion_BranchName}}"
Write-Output "GitVersion_SemVer: ${{needs.Setup.outputs.GitVersion_SemVer}}"
Write-Output "GitVersion_PreReleaseLabel: ${{needs.Setup.outputs.GitVersion_PreReleaseLabel}}"
Write-Output "GitVersion_AssemblySemVer: ${{needs.Setup.outputs.GitVersion_AssemblySemVer}}"
Write-Output "GitVersion_InformationalVersion: ${{needs.Setup.outputs.GitVersion_InformationalVersion}}"
Write-Output "GitVersion_NuGetVersion: ${{needs.Setup.outputs.GitVersion_NuGetVersion}}"
Write-Output "Filter_src: ${{needs.Setup.outputs.Filter_src}}"
Write-Output "Filter_docs: ${{needs.Setup.outputs.Filter_docs}}"
Write-Output "Filter_automation: ${{needs.Setup.outputs.Filter_automation}}"
Write-Output "nkdAgility_Ring: ${{needs.Setup.outputs.nkdAgility_Ring}}"
# Build, Test, Sonar Cloud Analysis, & Package
build:
name: "Build, Test, Sonar Cloud Analysis, & Package"
runs-on: windows-latest
needs: Setup
if: ${{ needs.Setup.outputs.Filter_src }}
env:
solution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
GitVersion_SemVer: ${{ needs.Setup.outputs.GitVersion_SemVer }}
GitVersion_AssemblySemVer: ${{ needs.Setup.outputs.GitVersion_AssemblySemVer }}
GitVersion_InformationalVersion: ${{ needs.Setup.outputs.GitVersion_InformationalVersion }}
GitVersion_NuGetVersion: ${{ needs.Setup.outputs.GitVersion_NuGetVersion }}
GitVersion_PreReleaseLabel: ${{ needs.Setup.outputs.GitVersion_PreReleaseLabel }}
steps:
# - name: Setup NuGet
# uses: NuGet/[email protected]
# - name: Restore NuGet Packages
# run: nuget restore MigrationTools.sln
# - name: Build and Publish Web App
# run: msbuild MigrationTools.sln
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: 17
distribution: 'zulu'
- name: Checkout
uses: actions/checkout@v2
- uses: cschleiden/replace-tokens@v1
with:
files: '["**/StaticVariables.cs"]'
tokenPrefix: "${"
tokenSuffix: "}"
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: |
8.x
- name: "Find solution files"
shell: pwsh
run: |
Get-Item -Path .\
Get-ChildItem -Path .\ -Recurse -Filter '*.sln' | ForEach-Object { $_.FullName }
- run: dotnet tool install --global dotnet-sonarscanner
- run: dotnet sonarscanner begin
/o:"nkdagility"
/k:"vsts-sync-migrator:master"
/d:sonar.host.url="https://sonarcloud.io"
/d:sonar.token="${{ secrets.SONAR_TOKEN }}"
- run: dotnet build MigrationTools.sln /p:Version=${{ env.GitVersion_SemVer }} /p:FileVersion=${{ env.GitVersion_AssemblySemVer }} /p:InformationalVersion=${{ env.GitVersion_InformationalVersion }} /p:GitVersionTag=${{ env.GitVersion_PreReleaseLabel }}
name: Build MigrationTools.sln
id: Build
- run: dotnet test "MigrationTools.sln" --results-directory ".\test-results\" --logger trx --collect "Code coverage" --no-build --filter "(TestCategory=L0|TestCategory=L1)"
- run: dotnet test "MigrationTools.sln" --results-directory ".\test-results\" --logger trx --collect "Code coverage" --no-build --filter "(TestCategory=L2|TestCategory=L3)"
- run: dotnet test "MigrationTools.sln" --results-directory ".\test-results\" --logger trx --collect "Code coverage" --no-build --filter "(TestCategory!=L0&TestCategory!=L1&TestCategory!=L2&TestCategory!=L3)"
- run: dotnet sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}"
- name: "Package Executable Files"
id: packageExecutable
shell: pwsh
if: ${{ steps.Build.outcome == 'success' }}
run: |
./build/packageExecutable.ps1 -version ${{ env.GitVersion_SemVer }} -outfolder "./staging"
- name: "Package Chocolatey Files"
shell: pwsh
if: ${{ steps.packageExecutable.outcome == 'success' }}
run: |
$item = Get-ChildItem -Path ./staging/ -Recurse -Filter 'MigrationTools-${{ env.GitVersion_SemVer }}.zip' | Select-Object -First 1
Write-Output "Found: $item.FullName"
.\build\packageChocolatey.ps1 -SemVer ${{ env.GitVersion_SemVer }} -NuGetVersion ${{ env.GitVersion_NuGetVersion }} -outfolder "./staging" -migrationToolsFilename $item.FullName
- name: "Package Extension Files"
shell: pwsh
if: ${{ steps.Build.outcome == 'success' }}
run: |
.\build\packageExtension.ps1 -version ${{ env.GitVersion_AssemblySemVer }} -outfolder "./staging"
- name: "List Package Files"
shell: pwsh
if: ${{ steps.Build.outcome == 'success' }}
run: |
Get-ChildItem -Path ./staging/ -Recurse | ForEach-Object { $_.FullName }
- uses: actions/upload-artifact@v4
with:
name: AzureDevOpsMigrationTools-Packages
path: ./staging/**
# Build Docs
BuildDocs:
name: "Build Documentation output"
runs-on: ubuntu-latest
needs: [Setup]
env:
GitVersion_SemVer: ${{ needs.Setup.outputs.GitVersion_SemVer }}
GitVersion_AssemblySemVer: ${{ needs.Setup.outputs.GitVersion_AssemblySemVer }}
GitVersion_InformationalVersion: ${{ needs.Setup.outputs.GitVersion_InformationalVersion }}
steps:
- uses: actions/checkout@v3
- uses: cschleiden/replace-tokens@v1
with:
files: '["**/*.html"]'
tokenPrefix: "${"
tokenSuffix: "}"
- uses: igsekor/[email protected]
id: spellcheck
name: Spellcheck
- name: Build Jekyll
uses: jerryjvl/jekyll-build-action@v1
- uses: actions/upload-artifact@v4
with:
name: AzureDevOpsMigrationTools-Site
path: ./_site/**/*
# GitHubRelease
GitHubRelease:
name: "Release to GitHub Releases (Not Migrated)"
runs-on: ubuntu-latest
if: ${{ needs.Setup.outputs.Filter_src }}
env:
GitVersion_SemVer: ${{ needs.Setup.outputs.GitVersion_SemVer }}
GitVersion_AssemblySemVer: ${{ needs.Setup.outputs.GitVersion_AssemblySemVer }}
GitVersion_InformationalVersion: ${{ needs.Setup.outputs.GitVersion_InformationalVersion }}
GitVersion_NuGetVersion: ${{ needs.Setup.outputs.GitVersion_NuGetVersion }}
GitVersion_PreReleaseLabel: ${{ needs.Setup.outputs.GitVersion_PreReleaseLabel }}
needs: [build, Setup]
#if: ${{ success() && ( needs.Setup.outputs.GitVersion_PreReleaseLabel == 'Preview' || needs.Setup.outputs.GitVersion_PreReleaseLabel == '' ) }}
steps:
- uses: actions/download-artifact@v4
with:
name: AzureDevOpsMigrationTools-Packages
- uses: actions/create-github-app-token@v1
id: app-token
with:
app-id: ${{ env.APP_ID }}
private-key: ${{ env.PRIVATE_KEY }}
- name: "Package Files"
shell: pwsh
run: |
Get-ChildItem -Path .\ -Recurse | ForEach-Object { $_.FullName }
- name: Release
if: ${{ false }}
uses: softprops/action-gh-release@v2
with:
files: |
MigrationTools-*.zip
nkdAgility.vsts-sync-migration-*.vsix
vsts-sync-migrator.*.nupkg
generate_release_notes: true
tag_name: v${{ needs.Setup.outputs.GitVersion_SemVer }}
name: Azure DevOps Migration Tools v${{ needs.Setup.outputs.GitVersion_SemVer }}
token: ${{ steps.app-token.outputs.token }}
prerelease: ${{ needs.Setup.outputs.GitVersion_PreReleaseLabel == 'Preview' }}
discussion_category_name: "Anouncement"
# Release to Marketplace
MarketplaceRelease:
name: "Release to Marketplace (Not Migrated)"
runs-on: ubuntu-latest
needs: [Setup, GitHubRelease]
if: ${{ (needs.Setup.outputs.Filter_src) && (false) }}
#if: ${{ success() && ( needs.Setup.outputs.GitVersion_PreReleaseLabel == 'Preview' || needs.Setup.outputs.GitVersion_PreReleaseLabel == '' ) }}
steps:
- uses: actions/download-artifact@v4
with:
name: AzureDevOpsMigrationTools-Packages
- name: "Find solution files"
shell: pwsh
run: |
Get-Item -Path .\
Get-ChildItem -Path .\ -Recurse -Filter '*.sln' | ForEach-Object { $_.FullName }
# Release to Chocolatey
ChocolateyRelease:
name: "Release to Chocolatey (Not Migrated)"
runs-on: ubuntu-latest
needs: [Setup, GitHubRelease]
if: ${{ (needs.Setup.outputs.Filter_src) && (false) }}
#if: ${{ success() && ( needs.Setup.outputs.GitVersion_PreReleaseLabel == 'Preview' || needs.Setup.outputs.GitVersion_PreReleaseLabel == '' ) }}
steps:
- uses: actions/download-artifact@v4
with:
name: AzureDevOpsMigrationTools-Packages
- name: "Find solution files"
shell: pwsh
run: |
Get-Item -Path .\
Get-ChildItem -Path .\ -Recurse -Filter '*.sln' | ForEach-Object { $_.FullName }
# Release to Winget
WingetRelease:
name: "Release to Winget (Not Migrated)"
runs-on: ubuntu-latest
needs: [Setup, GitHubRelease]
if: ${{ (needs.Setup.outputs.Filter_src) && (false) }}
#if: ${{ success() && ( needs.Setup.outputs.GitVersion_PreReleaseLabel == 'Preview' || needs.Setup.outputs.GitVersion_PreReleaseLabel == '' ) }}
steps:
- uses: actions/download-artifact@v4
with:
name: AzureDevOpsMigrationTools-Packages
- name: "Find solution files"
shell: pwsh
run: |
Get-Item -Path .\
Get-ChildItem -Path .\ -Recurse -Filter '*.sln' | ForEach-Object { $_.FullName }
# Release to Docs
DocsRelease:
name: "Release to Docs"
runs-on: ubuntu-latest
needs: [BuildDocs, GitHubRelease]
if: ${{ (needs.Setup.outputs.Filter_docs) && (false) }}
#if: ${{ success() && ( needs.Setup.outputs.GitVersion_PreReleaseLabel == 'Preview' || needs.Setup.outputs.GitVersion_PreReleaseLabel == '' ) }}
steps:
- name: Download a single artifact
uses: actions/download-artifact@v3
with:
name: AzureDevOpsMigrationTools-Site
path: ./_site
- name: "Find files"
shell: pwsh
run: |
Get-Item -Path .\
- name: SFTP Upload
# You may pin to the exact commit or the version.
# uses: Dylan700/sftp-upload-action@f90db607d9fe1acdc0eefccee84d37c119b268fe
uses: Dylan700/[email protected]
with:
server: nakedalmweb.sftp.wpengine.com
username: nakedalmweb-learn
password: ${{ secrets.SFTP_PASSWORD }}
port: 2222
# If true, outputs the results of the upload, without actually uploading.
dry-run: false
# A list of folders to upload in the format of `folder/ => upload_folder/`
uploads: |
./_site/ => ./azure-devops-migration-tools
# If true, any existing files in the remote upload directories are deleted.
delete: false