-
Notifications
You must be signed in to change notification settings - Fork 3
224 lines (188 loc) · 7.3 KB
/
Copy pathci-vsix.yml
File metadata and controls
224 lines (188 loc) · 7.3 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
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
name: CI - VSIX
on:
pull_request:
branches: [main]
paths-ignore:
- "**/*.md"
- "docs/**"
- ".github/**"
- "!.github/workflows/ci-vsix.yml"
- "src/XrmTools.Meta.Attributes/**"
push:
branches: [main]
paths-ignore:
- "**/*.md"
- "docs/**"
- "src/XrmTools.Meta.Attributes/**"
workflow_dispatch:
permissions:
contents: write # required to push tags
actions: read
checks: write # publish dorny test report checks
concurrency:
group: ci-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
CONFIGURATION: "Release"
SOLUTION_PATH: "src/XrmTools.slnx"
VSIX_PROJECT_DIR: "src/XrmTools/"
VSIX_MANIFEST_PATH: "src/XrmTools/source.extension.vsixmanifest"
VSIX_MANIFEST_SOURCE_PATH: "src/XrmTools/source.extension.cs"
TEST_RESULTS_DIR: "artifacts/test-results"
VSIX_STAGING_DIR: "artifacts/vsix"
jobs:
build:
name: Build & Test
runs-on: windows-latest
outputs:
version: ${{ steps.vsix_version.outputs['version-number'] }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Build Tooling
uses: timheuer/bootstrap-dotnet@v2
with:
msbuild: 'true'
sdk: 'true'
nuget: 'false'
- name: Stamp VSIX revision from run number
id: vsix_version
uses: timheuer/vsix-version-stamp@v2
with:
manifest-file: ${{ env.VSIX_MANIFEST_PATH }}
vsix-token-source-file: ${{ env.VSIX_MANIFEST_SOURCE_PATH }}
version-type: revision
build-number: ${{ github.run_number }}
- name: Build
run: msbuild "${{ env.SOLUTION_PATH }}" /v:m -restore /p:Configuration=${{ env.CONFIGURATION }}
- name: Create test results folder
shell: pwsh
run: |
New-Item -ItemType Directory -Force -Path "${{ env.TEST_RESULTS_DIR }}" | Out-Null
- name: Run unit tests (SDK-style) + TRX
shell: pwsh
run: |
$testProjects = Get-ChildItem -Path "src/Tests" -Recurse -Filter *.csproj |
Sort-Object FullName |
Select-Object -ExpandProperty FullName
if ($testProjects.Count -eq 0) {
throw "No test projects found under src/Tests."
}
foreach ($testProject in $testProjects) {
dotnet test $testProject `
-c "${{ env.CONFIGURATION }}" `
--no-build `
--logger "trx;LogFileName=$([System.IO.Path]::GetFileNameWithoutExtension($testProject))-test-results-${{ github.run_id }}.trx" `
--results-directory "${{ env.TEST_RESULTS_DIR }}"
if ($LASTEXITCODE -ne 0) {
throw "dotnet test failed for $testProject"
}
}
- name: Publish test report (PR Checks)
if: ${{ always() }}
uses: dorny/test-reporter@v1
with:
name: Unit Tests
path: ${{ env.TEST_RESULTS_DIR }}/*.trx
reporter: dotnet-trx
fail-on-error: true
- name: Upload test results artifact
if: ${{ always() }}
uses: actions/upload-artifact@v4
with:
name: test-results
path: ${{ env.TEST_RESULTS_DIR }}
- name: Stage VSIX
id: stage_vsix
shell: pwsh
run: |
New-Item -ItemType Directory -Force -Path "${{ env.VSIX_STAGING_DIR }}" | Out-Null
$searchRoot = Join-Path $env:GITHUB_WORKSPACE "${{ env.VSIX_PROJECT_DIR }}"
$files = Get-ChildItem -Path $searchRoot -Recurse -Filter *.vsix |
Where-Object { $_.FullName -notmatch '\\obj\\' }
if ($files.Count -eq 0) { throw "No .vsix produced under: $searchRoot" }
if ($files.Count -gt 1) {
$files | ForEach-Object { Write-Host $_.FullName }
throw "Multiple .vsix files produced under: $searchRoot. Narrow by name if needed."
}
$vsix = $files[0]
$dest = Join-Path $env:GITHUB_WORKSPACE "${{ env.VSIX_STAGING_DIR }}\$($vsix.Name)"
Copy-Item $vsix.FullName -Destination $dest -Force
"vsix_path=$dest" | Out-File -Append $env:GITHUB_OUTPUT
Write-Host "Staged VSIX: $dest"
- name: Upload VSIX artifact
uses: actions/upload-artifact@v4
with:
name: vsix
path: ${{ env.VSIX_STAGING_DIR }}/*.vsix
- name: Build summary
if: ${{ always() }}
shell: pwsh
run: |
$v = "${{ steps.vsix_version.outputs['version-number'] }}"
"### Build summary" | Out-File -Append $env:GITHUB_STEP_SUMMARY
"- Version stamped: **$v**" | Out-File -Append $env:GITHUB_STEP_SUMMARY
"- Configuration: **${{ env.CONFIGURATION }}**" | Out-File -Append $env:GITHUB_STEP_SUMMARY
publish_openvsix_and_tag:
name: Publish Nightly (Open VSIX) + Tag
if: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }}
needs: build
runs-on: windows-latest
env:
NIGHTLY_TAG: nightly/vsix/${{ needs.build.outputs.version }}
steps:
- name: Checkout (for tagging)
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download VSIX artifact
uses: actions/download-artifact@v4
with:
name: vsix
path: _staging
- name: Locate VSIX (from artifact)
id: locate_vsix
shell: pwsh
run: |
$files = Get-ChildItem -Path "$env:GITHUB_WORKSPACE\_staging" -Recurse -Filter *.vsix
if ($files.Count -eq 0) { throw "No .vsix found in downloaded artifact." }
if ($files.Count -gt 1) {
$files | ForEach-Object { Write-Host $_.FullName }
throw "Multiple .vsix files found in artifact. Narrow the search."
}
"vsix=$($files[0].FullName)" | Out-File -Append $env:GITHUB_OUTPUT
Write-Host "Using VSIX: $($files[0].FullName)"
- name: Publish to Open VSIX Gallery (nightly)
uses: timheuer/openvsixpublish@v1
with:
vsix-file: ${{ steps.locate_vsix.outputs.vsix }}
- name: Guard - version output must not be empty
shell: pwsh
run: |
$v = "${{ needs.build.outputs.version }}"
if ([string]::IsNullOrWhiteSpace($v)) { throw "Version output is empty; refusing to tag nightly/." }
- name: Guard - nightly tag must not already exist
shell: pwsh
run: |
$tag = "${{ env.NIGHTLY_TAG }}"
git fetch --tags --force
if (git tag -l $tag) { throw "Nightly tag '$tag' already exists. Refusing to overwrite." }
- name: Create and push nightly tag
shell: pwsh
run: |
$tag = "${{ env.NIGHTLY_TAG }}"
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git tag $tag
git push origin $tag
- name: Write summary
shell: pwsh
run: |
$version = "${{ needs.build.outputs.version }}"
$tag = "${{ env.NIGHTLY_TAG }}"
"### VSIX nightly published" | Out-File -Append $env:GITHUB_STEP_SUMMARY
"" | Out-File -Append $env:GITHUB_STEP_SUMMARY
"- Version: **$version**" | Out-File -Append $env:GITHUB_STEP_SUMMARY
"- Tag: **$tag**" | Out-File -Append $env:GITHUB_STEP_SUMMARY