Skip to content

Commit f36bdfe

Browse files
authored
Merge pull request #50 from TomasPecinka/49-issue-131-set-up-cicd-pipeline
49 issue 131 set up cicd pipeline
2 parents 0401a88 + 0566f09 commit f36bdfe

4 files changed

Lines changed: 134 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
branches: [main]
6+
push:
7+
branches: ['**']
8+
9+
concurrency:
10+
group: ci-${{ github.ref }}
11+
cancel-in-progress: true
12+
13+
jobs:
14+
build-test:
15+
runs-on: windows-latest
16+
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v5
20+
21+
- name: Setup .NET
22+
uses: actions/setup-dotnet@v5
23+
with:
24+
dotnet-version: 8.0.x
25+
26+
- name: Restore
27+
run: dotnet restore ExpressionTreeExplorer.sln
28+
29+
- name: Build
30+
run: dotnet build ExpressionTreeExplorer.sln -c Release --no-restore
31+
32+
- name: Test
33+
run: dotnet test ExpressionTreeExplorer.sln -c Release --no-build
34+
35+
- name: Upload VSIX artifact
36+
uses: actions/upload-artifact@v5
37+
with:
38+
name: vsix
39+
path: ExpressionTreeExplorer.Vsix/bin/Release/net8.0-windows/*.vsix
40+
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@v5
18+
19+
- name: Setup .NET
20+
uses: actions/setup-dotnet@v5
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

ExpressionTreeExplorer.sln

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ EndProject
1616
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{EFA536C3-BDAB-4FDC-B027-57093787EE4D}"
1717
ProjectSection(SolutionItems) = preProject
1818
CHANGELOG.md = CHANGELOG.md
19+
.github\workflows\ci.yml = .github\workflows\ci.yml
1920
README.md = README.md
21+
.github\workflows\release.yml = .github\workflows\release.yml
2022
EndProjectSection
2123
EndProject
2224
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docs", "docs", "{82145272-2E3A-4FFB-8D07-065A530D5499}"

global.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"sdk": {
3+
"version": "8.0.0",
4+
"rollForward": "latestMinor"
5+
}
6+
}

0 commit comments

Comments
 (0)