|
| 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