|
| 1 | +name: Release - ResultR.VSToolkit |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - 'vstoolkit-v*' |
| 7 | + |
| 8 | +permissions: |
| 9 | + contents: write |
| 10 | + |
| 11 | +jobs: |
| 12 | + release-vstoolkit: |
| 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: Setup MSBuild |
| 25 | + uses: microsoft/setup-msbuild@v2 |
| 26 | + |
| 27 | + - name: Setup NuGet |
| 28 | + uses: NuGet/setup-nuget@v2 |
| 29 | + |
| 30 | + - name: Restore dependencies |
| 31 | + run: nuget restore ResultR.VSToolkit.csproj |
| 32 | + working-directory: src/ResultR.VSToolkit |
| 33 | + |
| 34 | + - name: Build VSIX |
| 35 | + run: msbuild ResultR.VSToolkit.csproj /p:Configuration=Release /p:DeployExtension=false |
| 36 | + working-directory: src/ResultR.VSToolkit |
| 37 | + |
| 38 | + - name: Get version from tag |
| 39 | + id: version |
| 40 | + shell: pwsh |
| 41 | + run: | |
| 42 | + $version = "${{ github.ref_name }}" -replace 'vstoolkit-v', '' |
| 43 | + echo "VERSION=$version" >> $env:GITHUB_OUTPUT |
| 44 | +
|
| 45 | + - name: Rename VSIX with version |
| 46 | + shell: pwsh |
| 47 | + run: | |
| 48 | + $vsixPath = Get-ChildItem -Path "src/ResultR.VSToolkit/bin/Release" -Filter "*.vsix" -Recurse | Select-Object -First 1 |
| 49 | + if ($vsixPath) { |
| 50 | + $newName = "ResultR.VSToolkit.${{ steps.version.outputs.VERSION }}.vsix" |
| 51 | + $newPath = Join-Path $vsixPath.DirectoryName $newName |
| 52 | + Move-Item -Path $vsixPath.FullName -Destination $newPath |
| 53 | + echo "VSIX_PATH=$newPath" >> $env:GITHUB_OUTPUT |
| 54 | + } else { |
| 55 | + Write-Error "No VSIX file found" |
| 56 | + exit 1 |
| 57 | + } |
| 58 | + id: rename |
| 59 | + |
| 60 | + - name: Publish to Visual Studio Marketplace |
| 61 | + shell: pwsh |
| 62 | + run: | |
| 63 | + # Download VsixPublisher |
| 64 | + $vsixPublisherPath = "${env:ProgramFiles}\Microsoft Visual Studio\2022\Enterprise\VSSDK\VisualStudioIntegration\Tools\Bin\VsixPublisher.exe" |
| 65 | + |
| 66 | + # If not found in Enterprise, try other editions |
| 67 | + if (-not (Test-Path $vsixPublisherPath)) { |
| 68 | + $vsixPublisherPath = "${env:ProgramFiles}\Microsoft Visual Studio\2022\Professional\VSSDK\VisualStudioIntegration\Tools\Bin\VsixPublisher.exe" |
| 69 | + } |
| 70 | + if (-not (Test-Path $vsixPublisherPath)) { |
| 71 | + $vsixPublisherPath = "${env:ProgramFiles}\Microsoft Visual Studio\2022\Community\VSSDK\VisualStudioIntegration\Tools\Bin\VsixPublisher.exe" |
| 72 | + } |
| 73 | + |
| 74 | + # Use nuget to get VsixPublisher if not found |
| 75 | + if (-not (Test-Path $vsixPublisherPath)) { |
| 76 | + nuget install Microsoft.VSSDK.BuildTools -Version 17.11.439 -OutputDirectory .tools |
| 77 | + $vsixPublisherPath = Get-ChildItem -Path ".tools" -Filter "VsixPublisher.exe" -Recurse | Select-Object -First 1 -ExpandProperty FullName |
| 78 | + } |
| 79 | + |
| 80 | + if (-not $vsixPublisherPath -or -not (Test-Path $vsixPublisherPath)) { |
| 81 | + Write-Error "VsixPublisher.exe not found" |
| 82 | + exit 1 |
| 83 | + } |
| 84 | + |
| 85 | + # Publish to marketplace |
| 86 | + & $vsixPublisherPath publish ` |
| 87 | + -payload "${{ steps.rename.outputs.VSIX_PATH }}" ` |
| 88 | + -publishManifest "src/ResultR.VSToolkit/Resources/publishManifest.json" ` |
| 89 | + -personalAccessToken "${{ secrets.VS_MARKETPLACE_TOKEN }}" |
| 90 | + env: |
| 91 | + VS_MARKETPLACE_TOKEN: ${{ secrets.VS_MARKETPLACE_TOKEN }} |
| 92 | + |
| 93 | + - name: Create GitHub Release |
| 94 | + uses: softprops/action-gh-release@v2 |
| 95 | + with: |
| 96 | + files: | |
| 97 | + ${{ steps.rename.outputs.VSIX_PATH }} |
| 98 | + generate_release_notes: true |
| 99 | + draft: false |
| 100 | + prerelease: false |
| 101 | + name: ResultR.VSToolkit v${{ steps.version.outputs.VERSION }} |
| 102 | + body: | |
| 103 | + ## ResultR Visual Studio Extension v${{ steps.version.outputs.VERSION }} |
| 104 | + |
| 105 | + Navigate from `IRequest`/`IRequest<T>` classes to their corresponding `IRequestHandler` implementations with a single keystroke. |
| 106 | + |
| 107 | + ### Installation |
| 108 | + - **Visual Studio Marketplace**: Search for "AlanBarber.ResultR-VSToolkit" in Extensions |
| 109 | + - **Manual**: Download the `.vsix` file below and double-click to install |
| 110 | + env: |
| 111 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments