1- # This workflow will build a .NET project
2- # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net
1+ # TypeScript Definition Generator — VSIX and Rider plugin build
2+ # https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net
33
44name : .NET
55
@@ -14,111 +14,107 @@ on:
1414 pull_request :
1515 branches :
1616 - master
17- workflow_dispatch : # <-- вот это даёт ручной запуск
17+ workflow_dispatch :
1818
1919jobs :
2020 build :
21- permissions : # <-- https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax#defining-access-for-the-github_token-scopes
21+ permissions :
2222 contents : write
2323
2424 env :
25- BUILD_CONFIG : ' Release'
26- SOLUTION : ' Cross.EdiEngine.sln '
25+ BUILD_CONFIG : Release
26+ SOLUTION : TypeScriptDefinitionGenerator.slnx
2727
28- runs-on : ubuntu-22.04 # ubuntu-latest
28+ runs-on : windows-latest
29+ defaults :
30+ run :
31+ shell : pwsh
2932
3033 steps :
3134 - name : Checkout
3235 uses : actions/checkout@v4
3336 with :
34- # Disabling shallow clones is recommended for improving the relevancy of reporting
3537 fetch-depth : 0
3638
37- - name : Setup .NET
38- uses : actions /setup-dotnet@v4
39+ - name : Setup MSBuild
40+ uses : microsoft /setup-msbuild@v2
3941 with :
40- dotnet-version : |
41- 6.0.x
42- 7.0.x
43- 8.0.x
44- 9.0.x
45- 10.0.x
42+ vs-version : " [17.0,18.0)"
4643
47- - name : Setup NuGet
48- uses : NuGet/setup-nuget@v2.0.0
44+ - name : Setup Java 17
45+ uses : actions/setup-java@v4
46+ with :
47+ distribution : microsoft
48+ java-version : " 17"
4949
5050 - name : Install GitVersion
5151 uses : gittools/actions/gitversion/setup@v1.1.1
5252 with :
5353 versionSpec : 5.12.0
5454
5555 - name : Determine Version
56+ id : gitversion
5657 uses : gittools/actions/gitversion/execute@v1.1.1
5758 with :
5859 useConfigFile : true
5960
60- - name : Restore dependencies
61- run : dotnet restore
62-
63- - name : Build
61+ - name : Increment VSIX version
62+ if : github.ref == 'refs/heads/master' && github.event_name != 'pull_request'
6463 run : |
65- dotnet build "$SOLUTION" --configuration "$BUILD_CONFIG" --no-restore \
66- -p:Configuration=$BUILD_CONFIG \
67- -p:Version=${GitVersion_SemVer} \
68- -p:AssemblyVersion=${GitVersion_AssemblySemVer} \
69- -p:FileVersion=${GitVersion_AssemblySemFileVer} \
70- -p:InformationalVersion="${GitVersion_InformationalVersion}" \
71- -p:Company="Denis Peshkov" \
72- -p:Product="Cross.EdiEngine" \
73- -p:Description="Cross.EdiEngine: Simple .NET EDI Reader and Writer and Validator. Read and Write and Validate X12 EDI files with simple EDI Parser written on C#. Published on Nuget at https://www.nuget.org/packages/Cross.EdiEngine" \
74- -p:RepositoryUrl="https://github.com/denis-peshkov/Cross.EdiEngine.git" \
75- -p:RepositoryType=git \
76- -p:CLSCompliant=true \
77- -p:NeutralLanguage=en
78-
79- - name : Run tests
80- run : dotnet test /p:Configuration=$BUILD_CONFIG --no-restore --no-build --verbosity normal
81-
82- - name : SonarQube Scan
83- uses : sonarsource/sonarcloud-github-action@v5 # Ex: v4.0.0, See the latest version at https://github.com/marketplace/actions/sonarcloud-scan
84- with :
85- # projectBaseDir: app/
86- # args: >
87- # -Dsonar.organization=peshkov
88- # -Dsonar.projectKey=Cross.EdiEngine
89- # -Dsonar.python.coverage.reportPaths=coverage.xml
90- # -Dsonar.sources=Cross.EdiEngine/
91- # -Dsonar.tests=tests/
92- # -Dsonar.test.exclusions=tests/**
93- # -Dsonar.verbose=true
94- args : >
95- -Dsonar.organization=peshkov
96- -Dsonar.projectKey=Cross.EdiEngine
97- -Dsonar.python.coverage.reportPaths=coverage.xml
98- -Dsonar.sources=EdiEngine/
99- -Dsonar.verbose=true
100- env :
101- SONAR_TOKEN : ${{ secrets.SONAR_TOKEN }}
102-
103- - name : Nuget Pack
104- run : nuget pack _nuget/config.nuspec -Symbols -Version ${{ env.semVer }}
105-
106- - name : ref
107- run : echo "github.head_ref 1 ${{ github.head_ref }} 2 $GITHUB_REF 3 ${{ github.ref }}"
108-
109- - name : Create git Tag
110- if : ${{ contains('refs/heads/hotfix', github.ref) || contains('refs/heads/release', github.ref) || contains('refs/heads/master', github.ref) }}
64+ $manifest = "src/TypeScriptDefinitionGenerator/source.extension.vsixmanifest"
65+ $csFile = "src/TypeScriptDefinitionGenerator/source.extension.cs"
66+ $newVersion = "${{ steps.gitversion.outputs.assemblySemFileVer }}"
67+ if ([string]::IsNullOrWhiteSpace($newVersion)) { $newVersion = "${{ steps.gitversion.outputs.majorMinorPatch }}.0" }
68+ $initialVersion = "2.2.0.0"
69+ [xml]$xml = Get-Content $manifest
70+ $ns = New-Object System.Xml.XmlNamespaceManager $xml.NameTable
71+ $ns.AddNamespace("ns", $xml.DocumentElement.NamespaceURI) | Out-Null
72+ $attr = $xml.SelectSingleNode("//ns:Identity", $ns).Attributes["Version"]
73+ $attr.Value = $newVersion
74+ $xml.Save($manifest)
75+ (Get-Content $csFile) -replace [regex]::Escape($initialVersion), $newVersion | Set-Content $csFile
76+ echo "VERSION=$newVersion" >> $env:GITHUB_ENV
77+
78+ - name : Restore
79+ run : msbuild $env:SOLUTION /t:restore /p:configuration=$env:BUILD_CONFIG /v:m
80+
81+ - name : Build VSIX
82+ run : msbuild $env:SOLUTION /t:TypeScriptDefinitionGenerator /p:configuration=$env:BUILD_CONFIG /p:DeployExtension=false /p:ZipPackageCompressionLevel=normal /v:m
83+
84+ - name : Build Rider plugin
85+ run : bash build-rider-plugin.sh $env:BUILD_CONFIG ${{ steps.gitversion.outputs.semVer }}
86+
87+ - name : Publish to VSIX Gallery
88+ if : github.ref == 'refs/heads/master' && github.event_name != 'pull_request'
11189 run : |
112- git tag v${{ env.semVer }}
90+ $vsix = Get-ChildItem -Path . -Filter "*.vsix" -Recurse | Where-Object { $_.FullName -like "*TypeScriptDefinitionGenerator*" -and $_.FullName -notlike "*obj*" } | Sort-Object LastWriteTime -Descending | Select-Object -First 1
91+ if ($vsix) {
92+ $repo = [System.Web.HttpUtility]::UrlEncode("https://github.com/$env:GITHUB_REPOSITORY/")
93+ $issueTracker = [System.Web.HttpUtility]::UrlEncode("https://github.com/$env:GITHUB_REPOSITORY/issues/")
94+ Add-Type -AssemblyName System.Web
95+ $url = "http://vsixgallery.com/api/upload?repo=$repo&issuetracker=$issueTracker"
96+ Invoke-WebRequest $url -Method Post -Body ([System.IO.File]::ReadAllBytes($vsix.FullName)) -UseBasicParsing
97+ Write-Host "VSIX Gallery: OK"
98+ }
99+
100+ - name : Publish to marketplaces
101+ if : github.ref == 'refs/heads/master' && github.event_name != 'pull_request'
102+ run : ./publish-marketplace.ps1
103+ env :
104+ VS_MARKETPLACE_PAT : ${{ secrets.VS_MARKETPLACE_PAT }}
105+ JETBRAINS_MARKETPLACE_TOKEN : ${{ secrets.JETBRAINS_MARKETPLACE_TOKEN }}
113106
114- - name : Push git Tag
115- if : ${{ contains(fromJson('["refs/heads/master", "refs/heads/release", "refs/heads/hotfix"]'), github.ref) }}
107+ - name : Prepare artifacts
116108 run : |
117- git config --global user.name 'Denis Peshkov'
118- git config --global user.email 'denis.peshkov@outlook.com'
119- git remote set-url origin https://x-access-token:${{ secrets.TAGTOKEN }}@github.com/${{ github.repository }}
120- git push origin v${{ env.semVer }}
121-
122- - name : Nuget Push
123- if : ${{ !startsWith(github.ref, 'refs/pull') }}
124- run : nuget push **/Cross.EdiEngine.${{ env.semVer }}.symbols.nupkg -ApiKey ${{ secrets.NUGET_API_KEY }} -Source "https://api.nuget.org/v3/index.json" -SkipDuplicate
109+ New-Item -ItemType Directory -Path artifacts -Force
110+ $vsix = Get-ChildItem -Path . -Filter "*.vsix" -Recurse -ErrorAction SilentlyContinue | Where-Object { $_.FullName -like "*TypeScriptDefinitionGenerator*" -and $_.FullName -notlike "*obj*" } | Select-Object -First 1
111+ if ($vsix) { Copy-Item $vsix.FullName -Destination "artifacts/TypeScriptDefinitionGenerator.vsix" -Force }
112+ $riderVer = "${{ steps.gitversion.outputs.semVer }}"
113+ $riderZip = "output/TypeScriptDefinitionGenerator.Rider-$riderVer.zip"
114+ if (Test-Path $riderZip) { Copy-Item $riderZip -Destination "artifacts/" -Force }
115+
116+ - name : Upload artifacts
117+ uses : actions/upload-artifact@v4
118+ with :
119+ name : build-artifacts
120+ path : artifacts/
0 commit comments