Bump Xrm Tools extension version to 2.0.0 #119
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI - VSIX | |
| on: | |
| pull_request: | |
| branches: [main] | |
| paths-ignore: | |
| - "**/*.md" | |
| - "docs/**" | |
| - ".github/**" | |
| - "!.github/workflows/ci-vsix.yml" | |
| - "src/XrmTools.Meta.Attributes/**" | |
| push: | |
| branches: [main] | |
| paths-ignore: | |
| - "**/*.md" | |
| - "docs/**" | |
| - "src/XrmTools.Meta.Attributes/**" | |
| workflow_dispatch: | |
| permissions: | |
| contents: write # required to push tags | |
| actions: read | |
| checks: write # publish dorny test report checks | |
| concurrency: | |
| group: ci-${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| env: | |
| CONFIGURATION: "Release" | |
| SOLUTION_PATH: "src/XrmTools.slnx" | |
| VSIX_PROJECT_DIR: "src/XrmTools/" | |
| VSIX_MANIFEST_PATH: "src/XrmTools/source.extension.vsixmanifest" | |
| VSIX_MANIFEST_SOURCE_PATH: "src/XrmTools/source.extension.cs" | |
| TEST_RESULTS_DIR: "artifacts/test-results" | |
| VSIX_STAGING_DIR: "artifacts/vsix" | |
| jobs: | |
| build: | |
| name: Build & Test | |
| runs-on: windows-latest | |
| outputs: | |
| version: ${{ steps.vsix_version.outputs['version-number'] }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup Build Tooling | |
| uses: timheuer/bootstrap-dotnet@v2 | |
| with: | |
| msbuild: 'true' | |
| sdk: 'true' | |
| nuget: 'false' | |
| - name: Stamp VSIX revision from run number | |
| id: vsix_version | |
| uses: timheuer/vsix-version-stamp@v2 | |
| with: | |
| manifest-file: ${{ env.VSIX_MANIFEST_PATH }} | |
| vsix-token-source-file: ${{ env.VSIX_MANIFEST_SOURCE_PATH }} | |
| version-type: revision | |
| build-number: ${{ github.run_number }} | |
| - name: Build | |
| run: msbuild "${{ env.SOLUTION_PATH }}" /v:m -restore /p:Configuration=${{ env.CONFIGURATION }} | |
| - name: Create test results folder | |
| shell: pwsh | |
| run: | | |
| New-Item -ItemType Directory -Force -Path "${{ env.TEST_RESULTS_DIR }}" | Out-Null | |
| - name: Run unit tests (SDK-style) + TRX | |
| shell: pwsh | |
| run: | | |
| $testProjects = Get-ChildItem -Path "src/Tests" -Recurse -Filter *.csproj | | |
| Sort-Object FullName | | |
| Select-Object -ExpandProperty FullName | |
| if ($testProjects.Count -eq 0) { | |
| throw "No test projects found under src/Tests." | |
| } | |
| foreach ($testProject in $testProjects) { | |
| dotnet test $testProject ` | |
| -c "${{ env.CONFIGURATION }}" ` | |
| --no-build ` | |
| --logger "trx;LogFileName=$([System.IO.Path]::GetFileNameWithoutExtension($testProject))-test-results-${{ github.run_id }}.trx" ` | |
| --results-directory "${{ env.TEST_RESULTS_DIR }}" | |
| if ($LASTEXITCODE -ne 0) { | |
| throw "dotnet test failed for $testProject" | |
| } | |
| } | |
| - name: Publish test report (PR Checks) | |
| if: ${{ always() }} | |
| uses: dorny/test-reporter@v1 | |
| with: | |
| name: Unit Tests | |
| path: ${{ env.TEST_RESULTS_DIR }}/*.trx | |
| reporter: dotnet-trx | |
| fail-on-error: true | |
| - name: Upload test results artifact | |
| if: ${{ always() }} | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: test-results | |
| path: ${{ env.TEST_RESULTS_DIR }} | |
| - name: Stage VSIX | |
| id: stage_vsix | |
| shell: pwsh | |
| run: | | |
| New-Item -ItemType Directory -Force -Path "${{ env.VSIX_STAGING_DIR }}" | Out-Null | |
| $searchRoot = Join-Path $env:GITHUB_WORKSPACE "${{ env.VSIX_PROJECT_DIR }}" | |
| $files = Get-ChildItem -Path $searchRoot -Recurse -Filter *.vsix | | |
| Where-Object { $_.FullName -notmatch '\\obj\\' } | |
| if ($files.Count -eq 0) { throw "No .vsix produced under: $searchRoot" } | |
| if ($files.Count -gt 1) { | |
| $files | ForEach-Object { Write-Host $_.FullName } | |
| throw "Multiple .vsix files produced under: $searchRoot. Narrow by name if needed." | |
| } | |
| $vsix = $files[0] | |
| $dest = Join-Path $env:GITHUB_WORKSPACE "${{ env.VSIX_STAGING_DIR }}\$($vsix.Name)" | |
| Copy-Item $vsix.FullName -Destination $dest -Force | |
| "vsix_path=$dest" | Out-File -Append $env:GITHUB_OUTPUT | |
| Write-Host "Staged VSIX: $dest" | |
| - name: Upload VSIX artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: vsix | |
| path: ${{ env.VSIX_STAGING_DIR }}/*.vsix | |
| - name: Build summary | |
| if: ${{ always() }} | |
| shell: pwsh | |
| run: | | |
| $v = "${{ steps.vsix_version.outputs['version-number'] }}" | |
| "### Build summary" | Out-File -Append $env:GITHUB_STEP_SUMMARY | |
| "- Version stamped: **$v**" | Out-File -Append $env:GITHUB_STEP_SUMMARY | |
| "- Configuration: **${{ env.CONFIGURATION }}**" | Out-File -Append $env:GITHUB_STEP_SUMMARY | |
| publish_openvsix_and_tag: | |
| name: Publish Nightly (Open VSIX) + Tag | |
| if: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }} | |
| needs: build | |
| runs-on: windows-latest | |
| env: | |
| NIGHTLY_TAG: nightly/vsix/${{ needs.build.outputs.version }} | |
| steps: | |
| - name: Checkout (for tagging) | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Download VSIX artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: vsix | |
| path: _staging | |
| - name: Locate VSIX (from artifact) | |
| id: locate_vsix | |
| shell: pwsh | |
| run: | | |
| $files = Get-ChildItem -Path "$env:GITHUB_WORKSPACE\_staging" -Recurse -Filter *.vsix | |
| if ($files.Count -eq 0) { throw "No .vsix found in downloaded artifact." } | |
| if ($files.Count -gt 1) { | |
| $files | ForEach-Object { Write-Host $_.FullName } | |
| throw "Multiple .vsix files found in artifact. Narrow the search." | |
| } | |
| "vsix=$($files[0].FullName)" | Out-File -Append $env:GITHUB_OUTPUT | |
| Write-Host "Using VSIX: $($files[0].FullName)" | |
| - name: Publish to Open VSIX Gallery (nightly) | |
| uses: timheuer/openvsixpublish@v1 | |
| with: | |
| vsix-file: ${{ steps.locate_vsix.outputs.vsix }} | |
| - name: Guard - version output must not be empty | |
| shell: pwsh | |
| run: | | |
| $v = "${{ needs.build.outputs.version }}" | |
| if ([string]::IsNullOrWhiteSpace($v)) { throw "Version output is empty; refusing to tag nightly/." } | |
| - name: Guard - nightly tag must not already exist | |
| shell: pwsh | |
| run: | | |
| $tag = "${{ env.NIGHTLY_TAG }}" | |
| git fetch --tags --force | |
| if (git tag -l $tag) { throw "Nightly tag '$tag' already exists. Refusing to overwrite." } | |
| - name: Create and push nightly tag | |
| shell: pwsh | |
| run: | | |
| $tag = "${{ env.NIGHTLY_TAG }}" | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git tag $tag | |
| git push origin $tag | |
| - name: Write summary | |
| shell: pwsh | |
| run: | | |
| $version = "${{ needs.build.outputs.version }}" | |
| $tag = "${{ env.NIGHTLY_TAG }}" | |
| "### VSIX nightly published" | Out-File -Append $env:GITHUB_STEP_SUMMARY | |
| "" | Out-File -Append $env:GITHUB_STEP_SUMMARY | |
| "- Version: **$version**" | Out-File -Append $env:GITHUB_STEP_SUMMARY | |
| "- Tag: **$tag**" | Out-File -Append $env:GITHUB_STEP_SUMMARY |