-
Notifications
You must be signed in to change notification settings - Fork 0
86 lines (74 loc) · 2.82 KB
/
Copy pathrelease.yml
File metadata and controls
86 lines (74 loc) · 2.82 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
name: Release
on:
push:
tags:
- 'v*'
permissions:
contents: write
jobs:
release:
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: 8.0.x
- name: Verify tag matches project version
shell: pwsh
run: |
$tag = "${{ github.ref_name }}".TrimStart('v')
$csproj = "ExpressionTreeExplorer.Vsix/ExpressionTreeExplorer.Vsix.csproj"
$version = (Select-String -Path $csproj -Pattern '<Version>(.*?)</Version>').Matches[0].Groups[1].Value
Write-Host "Tag version: $tag"
Write-Host "Project version: $version"
if ($tag -ne $version) {
Write-Error "Tag ($tag) does not match <Version> in the .csproj ($version). Bump the project version before tagging."
exit 1
}
- name: Restore
run: dotnet restore ExpressionTreeExplorer.sln
- name: Build
run: dotnet build ExpressionTreeExplorer.sln -c Release --no-restore
- name: Test
run: dotnet test ExpressionTreeExplorer.sln -c Release --no-build
- name: Stage VSIX with versioned name
shell: pwsh
run: |
$version = "${{ github.ref_name }}".TrimStart('v')
$src = "ExpressionTreeExplorer.Vsix/bin/Release/net8.0-windows/ExpressionTreeExplorer.Vsix.vsix"
if (-not (Test-Path $src)) {
Write-Error "VSIX not found at $src"
exit 1
}
New-Item -ItemType Directory -Force -Path artifacts | Out-Null
Copy-Item $src "artifacts/ExpressionTreeExplorer-$version.vsix"
- name: Extract release notes from CHANGELOG
shell: pwsh
run: |
$version = "${{ github.ref_name }}".TrimStart('v')
$lines = Get-Content CHANGELOG.md
$notes = New-Object System.Collections.Generic.List[string]
$capture = $false
foreach ($line in $lines) {
if ($line -match '^## \[') {
if ($capture) { break }
if ($line -match "^## \[$([regex]::Escape($version))\]") { $capture = $true; continue }
}
elseif ($capture) {
$notes.Add($line)
}
}
$body = ($notes -join "`n").Trim()
if ([string]::IsNullOrWhiteSpace($body)) { $body = "Release $version" }
Set-Content -Path release-notes.md -Value $body -Encoding utf8
Write-Host "----- release notes -----"
Write-Host $body
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.ref_name }}
name: ${{ github.ref_name }}
body_path: release-notes.md
files: artifacts/ExpressionTreeExplorer-*.vsix