|
| 1 | +on: |
| 2 | + push: |
| 3 | + branches: |
| 4 | + - main |
| 5 | + tags: |
| 6 | + - v* |
| 7 | + - cli-v* |
| 8 | + pull_request: |
| 9 | + |
| 10 | +env: |
| 11 | + Configuration: Release |
| 12 | + TreatWarningsAsErrors: true |
| 13 | + WarningsNotAsErrors: 1591,NU5128 |
| 14 | + Deterministic: true |
| 15 | + RunCodeAnalysis: false |
| 16 | + |
| 17 | +jobs: |
| 18 | + pre_build: |
| 19 | + runs-on: ubuntu-20.04 |
| 20 | + outputs: |
| 21 | + version: ${{ steps.version.outputs.version }} |
| 22 | + version3: ${{ steps.version.outputs.version3 }} |
| 23 | + cliVersion: ${{ steps.cliVersion.outputs.version }} |
| 24 | + defaults: |
| 25 | + run: |
| 26 | + working-directory: src |
| 27 | + steps: |
| 28 | + - uses: actions/checkout@v3 |
| 29 | + with: |
| 30 | + fetch-depth: 0 |
| 31 | + - run: dotnet tool install -g GitVersion.Tool --version 5.12.0 |
| 32 | + - name: Resolve version |
| 33 | + id: version |
| 34 | + run: | |
| 35 | + dotnet-gitversion > version.json |
| 36 | + version="$(jq -r '.SemVer' version.json)" |
| 37 | + version3="$(jq -r '.MajorMinorPatch' version.json)" |
| 38 | + pr_version="$(jq -r '.MajorMinorPatch' version.json)-$(jq -r '.PreReleaseLabel' version.json).${{ github.run_number }}.${{ github.run_attempt }}" |
| 39 | + if [ "${{ github.event_name }}" = "pull_request" ]; then version=$pr_version; fi |
| 40 | + echo "Resolved version: $version" |
| 41 | + echo "version=${version}" >> $GITHUB_OUTPUT |
| 42 | + echo "Resolved version3: $version3" |
| 43 | + echo "version3=${version3}" >> $GITHUB_OUTPUT |
| 44 | + - name: Resolve CLI version |
| 45 | + id: cliVersion |
| 46 | + run: | |
| 47 | + dotnet-gitversion /overrideconfig tag-prefix=cli-v > version.json |
| 48 | + version="$(jq -r '.SemVer' version.json)" |
| 49 | + pr_version="$(jq -r '.MajorMinorPatch' version.json)-$(jq -r '.PreReleaseLabel' version.json).${{ github.run_number }}.${{ github.run_attempt }}" |
| 50 | + if [ "${{ github.event_name }}" = "pull_request" ]; then version=$pr_version; fi |
| 51 | + echo "Resolved CLI version: $version" |
| 52 | + echo "version=${version}" >> $GITHUB_OUTPUT |
| 53 | + - run: dotnet restore Roslynator.sln |
| 54 | + - run: dotnet build Roslynator.sln --no-restore |
| 55 | + - run: | |
| 56 | + dotnet format Roslynator.sln --no-restore --verify-no-changes --severity info --exclude-diagnostics \ |
| 57 | + IDE0220 `# 'foreach' statement implicitly converts type. Add an explicit cast to make intent clearer.` \ |
| 58 | + IDE0251 `# Property can be made read-only.` \ |
| 59 | + IDE0270 `# Null check can be simplified.` |
| 60 | + - run: dotnet test Roslynator.sln --no-build |
| 61 | + |
| 62 | + build_core_and_testing: |
| 63 | + if: github.ref_type != 'tag' || startsWith(github.ref_name, 'v') |
| 64 | + needs: pre_build |
| 65 | + runs-on: ubuntu-20.04 |
| 66 | + env: |
| 67 | + Version: ${{ needs.pre_build.outputs.version }} |
| 68 | + defaults: |
| 69 | + run: |
| 70 | + working-directory: src |
| 71 | + steps: |
| 72 | + - uses: actions/checkout@v3 |
| 73 | + - run: dotnet restore Roslynator.CoreAndTesting.slnf |
| 74 | + - run: dotnet build Roslynator.CoreAndTesting.slnf --no-restore |
| 75 | + - run: dotnet pack Roslynator.CoreAndTesting.slnf --no-build -o _nupkg |
| 76 | + - uses: actions/upload-artifact@v3 |
| 77 | + with: |
| 78 | + name: nuget_packages |
| 79 | + path: src/_nupkg/*nupkg |
| 80 | + |
| 81 | + build_analyzers: |
| 82 | + if: github.ref_type != 'tag' || startsWith(github.ref_name, 'v') |
| 83 | + needs: pre_build |
| 84 | + runs-on: ubuntu-20.04 |
| 85 | + env: |
| 86 | + Version: ${{ needs.pre_build.outputs.version }} |
| 87 | + strategy: |
| 88 | + matrix: |
| 89 | + component: |
| 90 | + - name: Analyzers |
| 91 | + propertyName: Analyzers |
| 92 | + - name: Formatting.Analyzers |
| 93 | + propertyName: FormattingAnalyzers |
| 94 | + - name: CodeAnalysis.Analyzers |
| 95 | + propertyName: CodeAnalysisAnalyzers |
| 96 | + defaults: |
| 97 | + run: |
| 98 | + working-directory: src/${{ matrix.component.name }}.CodeFixes |
| 99 | + steps: |
| 100 | + - uses: actions/checkout@v3 |
| 101 | + - run: dotnet restore |
| 102 | + - run: dotnet build --no-restore /p:Roslynator${{ matrix.component.propertyName }}NuGet=true |
| 103 | + - run: dotnet pack --no-build |
| 104 | + - uses: actions/upload-artifact@v3 |
| 105 | + with: |
| 106 | + name: nuget_packages |
| 107 | + path: src/${{ matrix.component.name }}.CodeFixes/bin/Release/*.nupkg |
| 108 | + |
| 109 | + build_vs_extension: |
| 110 | + if: github.ref_type != 'tag' || startsWith(github.ref_name, 'v') |
| 111 | + needs: pre_build |
| 112 | + runs-on: windows-latest |
| 113 | + env: |
| 114 | + Version: ${{ needs.pre_build.outputs.version }} |
| 115 | + DeployExtension: false |
| 116 | + defaults: |
| 117 | + run: |
| 118 | + working-directory: src/VisualStudio |
| 119 | + steps: |
| 120 | + - uses: actions/checkout@v3 |
| 121 | + - run: (Get-Content source.extension.vsixmanifest) -replace 'Version="1.0.0"', 'Version="${{ needs.pre_build.outputs.version3 }}"' | Set-Content source.extension.vsixmanifest |
| 122 | + - run: dotnet restore |
| 123 | + - uses: microsoft/[email protected] |
| 124 | + - run: msbuild |
| 125 | + - uses: actions/upload-artifact@v3 |
| 126 | + with: |
| 127 | + name: vs_extension |
| 128 | + path: src/VisualStudio/bin/Release/net472/*.vsix |
| 129 | + - uses: actions/upload-artifact@v3 |
| 130 | + with: |
| 131 | + name: vs_extension |
| 132 | + path: src/VisualStudio/manifest.json |
| 133 | + |
| 134 | + build_vs_code_extension: |
| 135 | + if: github.ref_type != 'tag' || startsWith(github.ref_name, 'v') |
| 136 | + needs: [ pre_build, build_analyzers ] |
| 137 | + runs-on: ubuntu-20.04 |
| 138 | + env: |
| 139 | + Version: ${{ needs.pre_build.outputs.version }} |
| 140 | + defaults: |
| 141 | + run: |
| 142 | + working-directory: src/VisualStudioCode |
| 143 | + steps: |
| 144 | + - uses: actions/checkout@v3 |
| 145 | + - run: dotnet restore |
| 146 | + - run: dotnet build --no-restore /p:DefineConstants=VSCODE |
| 147 | + - run: | |
| 148 | + mkdir package/roslyn/analyzers |
| 149 | + mkdir package/roslyn/refactorings |
| 150 | + mkdir package/roslyn/fixes |
| 151 | + cp bin/Release/netstandard2.0/Roslynator.Core.dll package/roslyn/common |
| 152 | + cp bin/Release/netstandard2.0/Roslynator.Common.dll package/roslyn/common |
| 153 | + cp bin/Release/netstandard2.0/Roslynator.CSharp.dll package/roslyn/common |
| 154 | + cp bin/Release/netstandard2.0/Roslynator.Workspaces.Core.dll package/roslyn/common |
| 155 | + cp bin/Release/netstandard2.0/Roslynator.Workspaces.Common.dll package/roslyn/common |
| 156 | + cp bin/Release/netstandard2.0/Roslynator.CSharp.Workspaces.dll package/roslyn/common |
| 157 | + cp bin/Release/netstandard2.0/Roslynator.CSharp.Analyzers.dll package/roslyn/analyzers |
| 158 | + cp bin/Release/netstandard2.0/Roslynator.CSharp.Analyzers.CodeFixes.dll package/roslyn/analyzers |
| 159 | + cp bin/Release/netstandard2.0/Roslynator.Formatting.Analyzers.dll package/roslyn/analyzers |
| 160 | + cp bin/Release/netstandard2.0/Roslynator.Formatting.Analyzers.CodeFixes.dll package/roslyn/analyzers |
| 161 | + cp bin/Release/netstandard2.0/Roslynator.CSharp.Refactorings.dll package/roslyn/refactorings |
| 162 | + cp bin/Release/netstandard2.0/Roslynator.CSharp.CodeFixes.dll package/roslyn/fixes |
| 163 | + name: Copy DLLs to package |
| 164 | + - run: > |
| 165 | + sed -i 's/"version": "1.0.0"/"version": "${{ needs.pre_build.outputs.version3 }}"/' package/package.json |
| 166 | + - run: npm install |
| 167 | + working-directory: src/VisualStudioCode/package |
| 168 | + - run: npm install -g @vscode/vsce |
| 169 | + - run: vsce package |
| 170 | + working-directory: src/VisualStudioCode/package |
| 171 | + - uses: actions/upload-artifact@v3 |
| 172 | + with: |
| 173 | + name: vs_code_extension |
| 174 | + path: src/VisualStudioCode/package/*.vsix |
| 175 | + - run: rm package/*.vsix |
| 176 | + - run: sed -i s/ms-dotnettools.csharp/muhammad-sammy.csharp/ package/package.json |
| 177 | + - run: vsce package |
| 178 | + working-directory: src/VisualStudioCode/package |
| 179 | + - uses: actions/upload-artifact@v3 |
| 180 | + with: |
| 181 | + name: ovsx_extension |
| 182 | + path: src/VisualStudioCode/package/*.vsix |
| 183 | + |
| 184 | + build_core_cli: |
| 185 | + if: github.ref_type != 'tag' || startsWith(github.ref_name, 'cli-v') |
| 186 | + needs: pre_build |
| 187 | + runs-on: ubuntu-20.04 |
| 188 | + env: |
| 189 | + RoslynatorDotNetCli: true |
| 190 | + RoslynatorCliVersion: ${{ needs.pre_build.outputs.cliVersion }} |
| 191 | + Version: ${{ needs.pre_build.outputs.version }} |
| 192 | + defaults: |
| 193 | + run: |
| 194 | + working-directory: src/CommandLine |
| 195 | + steps: |
| 196 | + - uses: actions/checkout@v3 |
| 197 | + - run: dotnet restore |
| 198 | + - run: dotnet build --no-restore |
| 199 | + - run: dotnet pack --no-build |
| 200 | + - uses: actions/upload-artifact@v3 |
| 201 | + with: |
| 202 | + name: nuget_packages |
| 203 | + path: src/CommandLine/bin/Release/*.nupkg |
| 204 | + |
| 205 | + build_framework_cli: |
| 206 | + if: github.ref_type != 'tag' || startsWith(github.ref_name, 'cli-v') |
| 207 | + needs: pre_build |
| 208 | + runs-on: windows-latest |
| 209 | + env: |
| 210 | + RoslynatorCommandLine: true |
| 211 | + RoslynatorCliVersion: ${{ needs.pre_build.outputs.cliVersion }} |
| 212 | + Version: ${{ needs.pre_build.outputs.version }} |
| 213 | + defaults: |
| 214 | + run: |
| 215 | + working-directory: src/CommandLine |
| 216 | + steps: |
| 217 | + - uses: actions/checkout@v3 |
| 218 | + - run: dotnet restore |
| 219 | + - run: dotnet build --no-restore |
| 220 | + - run: dotnet publish --no-build |
| 221 | + - run: dotnet pack --no-build |
| 222 | + - uses: actions/upload-artifact@v3 |
| 223 | + with: |
| 224 | + name: nuget_packages |
| 225 | + path: src/CommandLine/bin/Release/*.nupkg |
| 226 | + |
| 227 | + publish_nuget_packages: |
| 228 | + needs: [ build_core_and_testing, build_analyzers, build_core_cli, build_framework_cli ] |
| 229 | + runs-on: ubuntu-20.04 |
| 230 | + if: github.ref_type == 'tag' |
| 231 | + steps: |
| 232 | + - uses: actions/download-artifact@v3 |
| 233 | + with: |
| 234 | + name: nuget_packages |
| 235 | + path: nuget_packages |
| 236 | + - run: dotnet nuget push "*.nupkg" -k ${{ secrets.NUGET_API_KEY }} -s "https://api.nuget.org/v3/index.json" |
| 237 | + working-directory: nuget_packages |
| 238 | + |
| 239 | + publish_vs_code_extension: |
| 240 | + needs: build_vs_code_extension |
| 241 | + runs-on: ubuntu-20.04 |
| 242 | + if: github.ref_type == 'tag' && startsWith(github.ref_name, 'v') |
| 243 | + steps: |
| 244 | + - uses: actions/download-artifact@v3 |
| 245 | + with: |
| 246 | + name: vs_code_extension |
| 247 | + path: vs_code_extension |
| 248 | + - run: npm install -g @vscode/vsce |
| 249 | + - run: vsce publish -p ${{ secrets.VS_MARKETPLACE_TOKEN }} |
| 250 | + working-directory: vs_code_extension |
| 251 | + |
| 252 | + publish_ovsx_extension: |
| 253 | + needs: build_vs_code_extension |
| 254 | + runs-on: ubuntu-20.04 |
| 255 | + if: github.ref_type == 'tag' && startsWith(github.ref_name, 'v') |
| 256 | + steps: |
| 257 | + - uses: actions/download-artifact@v3 |
| 258 | + with: |
| 259 | + name: ovsx_extension |
| 260 | + path: ovsx_extension |
| 261 | + - run: npm install -g ovsx |
| 262 | + - run: ovsx publish -p ${{ secrets.OPEN_VSX_TOKEN }} |
| 263 | + working-directory: ovsx_extension |
| 264 | + |
| 265 | + publish_vs_extension: |
| 266 | + needs: build_vs_extension |
| 267 | + runs-on: windows-latest |
| 268 | + if: github.ref_type == 'tag' && startsWith(github.ref_name, 'v') |
| 269 | + steps: |
| 270 | + - uses: actions/download-artifact@v3 |
| 271 | + with: |
| 272 | + name: vs_extension |
| 273 | + path: vs_extension |
| 274 | + - run: | |
| 275 | + $visualStudioPath = vswhere -latest -products * -requires Microsoft.VisualStudio.Component.VSSDK -property installationPath |
| 276 | + $vsixPublisher = Join-Path "$visualStudioPath" "VSSDK\VisualStudioIntegration\Tools\Bin\VsixPublisher.exe" |
| 277 | + & "$vsixPublisher" publish -payload Roslynator.VisualStudio.vsix -publishManifest manifest.json -personalAccessToken ${{ secrets.VS_MARKETPLACE_TOKEN }} |
| 278 | + working-directory: vs_extension |
| 279 | + name: Publish VS extension to Marketplace |
0 commit comments