Skip to content

Commit 70a34ea

Browse files
committed
ci: add github actions pipeline for build, test and relaese
1 parent 0401a88 commit 70a34ea

2 files changed

Lines changed: 122 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
branches: [main]
6+
push:
7+
branches: [main]
8+
9+
jobs:
10+
build-test:
11+
runs-on: windows-latest
12+
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v4
16+
17+
- name: Setup .NET
18+
uses: actions/setup-dotnet@v4
19+
with:
20+
dotnet-version: 8.0.x
21+
22+
- name: Restore
23+
run: dotnet restore ExpressionTreeExplorer.sln
24+
25+
- name: Build
26+
run: dotnet build ExpressionTreeExplorer.sln -c Release --no-restore
27+
28+
- name: Test
29+
run: dotnet test ExpressionTreeExplorer.sln -c Release --no-build
30+
31+
- name: Upload VSIX artifact
32+
uses: actions/upload-artifact@v4
33+
with:
34+
name: vsix
35+
path: ExpressionTreeExplorer.Vsix/bin/Release/net8.0-windows/*.vsix
36+
if-no-files-found: error

.github/workflows/release.yml

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
release:
13+
runs-on: windows-latest
14+
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v4
18+
19+
- name: Setup .NET
20+
uses: actions/setup-dotnet@v4
21+
with:
22+
dotnet-version: 8.0.x
23+
24+
- name: Verify tag matches project version
25+
shell: pwsh
26+
run: |
27+
$tag = "${{ github.ref_name }}".TrimStart('v')
28+
$csproj = "ExpressionTreeExplorer.Vsix/ExpressionTreeExplorer.Vsix.csproj"
29+
$version = (Select-String -Path $csproj -Pattern '<Version>(.*?)</Version>').Matches[0].Groups[1].Value
30+
Write-Host "Tag version: $tag"
31+
Write-Host "Project version: $version"
32+
if ($tag -ne $version) {
33+
Write-Error "Tag ($tag) does not match <Version> in the .csproj ($version). Bump the project version before tagging."
34+
exit 1
35+
}
36+
37+
- name: Restore
38+
run: dotnet restore ExpressionTreeExplorer.sln
39+
40+
- name: Build
41+
run: dotnet build ExpressionTreeExplorer.sln -c Release --no-restore
42+
43+
- name: Test
44+
run: dotnet test ExpressionTreeExplorer.sln -c Release --no-build
45+
46+
- name: Stage VSIX with versioned name
47+
shell: pwsh
48+
run: |
49+
$version = "${{ github.ref_name }}".TrimStart('v')
50+
$src = "ExpressionTreeExplorer.Vsix/bin/Release/net8.0-windows/ExpressionTreeExplorer.Vsix.vsix"
51+
if (-not (Test-Path $src)) {
52+
Write-Error "VSIX not found at $src"
53+
exit 1
54+
}
55+
New-Item -ItemType Directory -Force -Path artifacts | Out-Null
56+
Copy-Item $src "artifacts/ExpressionTreeExplorer-$version.vsix"
57+
58+
- name: Extract release notes from CHANGELOG
59+
shell: pwsh
60+
run: |
61+
$version = "${{ github.ref_name }}".TrimStart('v')
62+
$lines = Get-Content CHANGELOG.md
63+
$notes = New-Object System.Collections.Generic.List[string]
64+
$capture = $false
65+
foreach ($line in $lines) {
66+
if ($line -match '^## \[') {
67+
if ($capture) { break }
68+
if ($line -match "^## \[$([regex]::Escape($version))\]") { $capture = $true; continue }
69+
}
70+
elseif ($capture) {
71+
$notes.Add($line)
72+
}
73+
}
74+
$body = ($notes -join "`n").Trim()
75+
if ([string]::IsNullOrWhiteSpace($body)) { $body = "Release $version" }
76+
Set-Content -Path release-notes.md -Value $body -Encoding utf8
77+
Write-Host "----- release notes -----"
78+
Write-Host $body
79+
80+
- name: Create GitHub Release
81+
uses: softprops/action-gh-release@v2
82+
with:
83+
tag_name: ${{ github.ref_name }}
84+
name: ${{ github.ref_name }}
85+
body_path: release-notes.md
86+
files: artifacts/ExpressionTreeExplorer-*.vsix

0 commit comments

Comments
 (0)