small fixes #6
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
| # TypeScript Definition Generator — VSIX and Rider plugin build | |
| # https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net | |
| name: CI | |
| on: | |
| push: | |
| branches: | |
| - master | |
| - dev | |
| - hotfix/* | |
| - release/* | |
| - feature/* | |
| pull_request: | |
| branches: | |
| - master | |
| workflow_dispatch: # <-- вот это даёт ручной запуск | |
| jobs: | |
| build: | |
| permissions: # <-- https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax#defining-access-for-the-github_token-scopes | |
| contents: write | |
| env: | |
| BUILD_CONFIG: Release | |
| SOLUTION: TypeScriptDefinitionGenerator.slnx | |
| runs-on: windows-2022 # windows-latest | |
| defaults: | |
| run: | |
| shell: pwsh | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| # Disabling shallow clones is recommended for improving the relevancy of reporting | |
| fetch-depth: 0 | |
| - name: Setup MSBuild | |
| uses: microsoft/setup-msbuild@v2 | |
| with: | |
| vs-version: "[17.0,18.0)" | |
| - name: Setup Java 17 | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: microsoft | |
| java-version: "17" | |
| - name: Install GitVersion | |
| uses: gittools/actions/gitversion/setup@v1.1.1 | |
| with: | |
| versionSpec: 5.12.0 | |
| - name: Determine Version | |
| uses: gittools/actions/gitversion/execute@v1.1.1 | |
| with: | |
| useConfigFile: true | |
| - name: Restore | |
| run: msbuild $env:SOLUTION /t:restore /p:configuration=$env:BUILD_CONFIG /v:m | |
| - name: Run tests | |
| run: dotnet test /p:Configuration=$BUILD_CONFIG --no-restore --no-build --verbosity normal | |
| - name: SonarQube Scan | |
| uses: sonarsource/sonarcloud-github-action@v5 # Ex: v4.0.0, See the latest version at https://github.com/marketplace/actions/sonarcloud-scan | |
| with: | |
| # projectBaseDir: app/ | |
| # args: > | |
| # -Dsonar.organization=peshkov | |
| # -Dsonar.projectKey=Cross.EdiEngine | |
| # -Dsonar.python.coverage.reportPaths=coverage.xml | |
| # -Dsonar.sources=Cross.EdiEngine/ | |
| # -Dsonar.tests=tests/ | |
| # -Dsonar.test.exclusions=tests/** | |
| # -Dsonar.verbose=true | |
| args: > | |
| -Dsonar.organization=peshkov | |
| -Dsonar.projectKey=Cross.EdiEngine | |
| -Dsonar.python.coverage.reportPaths=coverage.xml | |
| -Dsonar.sources=EdiEngine/ | |
| -Dsonar.verbose=true | |
| env: | |
| SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
| - name: Set NuGet package version | |
| run: | | |
| $nugetVersion = "${{ env.semVer }}" | |
| if ([string]::IsNullOrWhiteSpace($nugetVersion)) { $nugetVersion = "2.2.0" } | |
| (Get-Content "src/TypeScriptDefinitionGenerator.MSBuild/TypeScriptDefinitionGenerator.MSBuild.csproj") -replace '<PackageVersion>[^<]+</PackageVersion>', "<PackageVersion>$nugetVersion</PackageVersion>" | Set-Content "src/TypeScriptDefinitionGenerator.MSBuild/TypeScriptDefinitionGenerator.MSBuild.csproj" | |
| (Get-Content "src/TypeScriptDefinitionGenerator.MSBuild/TypeScriptDefinitionGenerator.MSBuild.props") -replace 'Version="[^"]+"', "Version=`"$nugetVersion`"" | Set-Content "src/TypeScriptDefinitionGenerator.MSBuild/TypeScriptDefinitionGenerator.MSBuild.props" | |
| echo "NUGET_VERSION=$nugetVersion" >> $env:GITHUB_ENV | |
| - name: Increment VSIX version | |
| if: github.ref == 'refs/heads/master' && github.event_name != 'pull_request' | |
| run: | | |
| $manifest = "src/TypeScriptDefinitionGenerator/source.extension.vsixmanifest" | |
| $csFile = "src/TypeScriptDefinitionGenerator/source.extension.cs" | |
| $vsixVersion = "${{ env.assemblySemVer }}" | |
| [xml]$xml = Get-Content $manifest | |
| $ns = New-Object System.Xml.XmlNamespaceManager $xml.NameTable | |
| $ns.AddNamespace("ns", $xml.DocumentElement.NamespaceURI) | Out-Null | |
| $xml.SelectSingleNode("//ns:Identity", $ns).Attributes["Version"].Value = $vsixVersion | |
| $xml.Save($manifest) | |
| (Get-Content $csFile) -replace 'Version = "[^"]*"', "Version = `"$vsixVersion`"" | Set-Content $csFile | |
| echo "VERSION=$vsixVersion" >> $env:GITHUB_ENV | |
| - name: Build VSIX | |
| run: > | |
| msbuild $env:SOLUTION \ | |
| /t:TypeScriptDefinitionGenerator \ | |
| /p:configuration=$env:BUILD_CONFIG \ | |
| /p:DeployExtension=false \ | |
| /p:ZipPackageCompressionLevel=normal \ | |
| /v:m | |
| - name: Build Rider plugin | |
| run: bash build-rider-plugin.sh $env:BUILD_CONFIG "${{ env.semVer }}" | |
| - name: Pack NuGet packages | |
| run: | | |
| New-Item -ItemType Directory -Path artifacts/nuget -Force | |
| dotnet pack src/TypeScriptDefinitionGenerator.Cli/TypeScriptDefinitionGenerator.Cli.csproj -c $env:BUILD_CONFIG -o artifacts/nuget -p:PackageVersion=$env:NUGET_VERSION | |
| dotnet pack src/TypeScriptDefinitionGenerator.MSBuild/TypeScriptDefinitionGenerator.MSBuild.csproj -c $env:BUILD_CONFIG -o artifacts/nuget -p:PackageVersion=$env:NUGET_VERSION | |
| - name: Publish to NuGet.org | |
| if: github.ref == 'refs/heads/master' && github.event_name != 'pull_request' | |
| run: | | |
| $pkgs = Get-ChildItem -Path artifacts/nuget -Filter "*.nupkg" -ErrorAction SilentlyContinue | |
| foreach ($pkg in $pkgs) { | |
| dotnet nuget push $pkg.FullName --source https://api.nuget.org/v3/index.json --api-key $env:NUGET_API_KEY --skip-duplicate | |
| } | |
| env: | |
| NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }} | |
| - name: ref | |
| run: echo "github.head_ref 1 ${{ github.head_ref }} 2 $GITHUB_REF 3 ${{ github.ref }}" | |
| - name: Create git Tag | |
| if: ${{ contains('refs/heads/hotfix', github.ref) || contains('refs/heads/release', github.ref) || contains('refs/heads/master', github.ref) }} | |
| run: | | |
| git tag v${{ env.semVer }} | |
| - name: Push git Tag | |
| if: ${{ contains(fromJson('["refs/heads/master", "refs/heads/release", "refs/heads/hotfix"]'), github.ref) }} | |
| run: | | |
| git config --global user.name 'Denis Peshkov' | |
| git config --global user.email 'denis.peshkov@outlook.com' | |
| git remote set-url origin https://x-access-token:${{ secrets.TAGTOKEN }}@github.com/${{ github.repository }} | |
| git push origin v${{ env.semVer }} | |
| - name: Publish to VSIX Gallery | |
| if: github.ref == 'refs/heads/master' && github.event_name != 'pull_request' | |
| run: | | |
| $vsix = Get-ChildItem -Path . -Filter "*.vsix" -Recurse | Where-Object { $_.FullName -like "*TypeScriptDefinitionGenerator*" -and $_.FullName -notlike "*obj*" } | Sort-Object LastWriteTime -Descending | Select-Object -First 1 | |
| if ($vsix) { | |
| $repo = [System.Web.HttpUtility]::UrlEncode("https://github.com/$env:GITHUB_REPOSITORY/") | |
| $issueTracker = [System.Web.HttpUtility]::UrlEncode("https://github.com/$env:GITHUB_REPOSITORY/issues/") | |
| Add-Type -AssemblyName System.Web | |
| $url = "http://vsixgallery.com/api/upload?repo=$repo&issuetracker=$issueTracker" | |
| Invoke-WebRequest $url -Method Post -Body ([System.IO.File]::ReadAllBytes($vsix.FullName)) -UseBasicParsing | |
| Write-Host "VSIX Gallery: OK" | |
| } | |
| - name: Publish to marketplaces | |
| if: github.ref == 'refs/heads/master' && github.event_name != 'pull_request' | |
| run: ./publish-marketplace.ps1 -RiderZipPath "output\TypeScriptDefinitionGenerator.Rider-${{ env.semVer }}.zip" | |
| env: | |
| VS_MARKETPLACE_PAT: ${{ secrets.VS_MARKETPLACE_PAT }} | |
| JETBRAINS_MARKETPLACE_TOKEN: ${{ secrets.JETBRAINS_MARKETPLACE_TOKEN }} | |
| - name: Prepare artifacts | |
| run: | | |
| New-Item -ItemType Directory -Path artifacts -Force | |
| $vsix = Get-ChildItem -Path . -Filter "*.vsix" -Recurse -ErrorAction SilentlyContinue | Where-Object { $_.FullName -like "*TypeScriptDefinitionGenerator*" -and $_.FullName -notlike "*obj*" } | Select-Object -First 1 | |
| if ($vsix) { Copy-Item $vsix.FullName -Destination "artifacts/TypeScriptDefinitionGenerator.vsix" -Force } | |
| if (Test-Path "output/TypeScriptDefinitionGenerator.Rider-${{ env.semVer }}.zip") { Copy-Item "output/TypeScriptDefinitionGenerator.Rider-${{ env.semVer }}.zip" -Destination "artifacts/" -Force } | |
| - name: Upload artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: build-artifacts | |
| path: artifacts/ |