Limit CI builds to main branch and PRs #1031
Workflow file for this run
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: NUnitConsoleAndEngine.CI | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| release: | |
| env: | |
| DOTNET_NOLOGO: true # Disable the .NET logo | |
| DOTNET_CLI_TELEMETRY_OPTOUT: true # Disable sending .NET CLI telemetry | |
| jobs: | |
| ContinuousIntegration: | |
| name: Continuous Integration | |
| runs-on: windows-latest | |
| env: | |
| MYGET_API_KEY: ${{ secrets.PUBLISH_MYGET_ORG }} | |
| NUGET_API_KEY: ${{ secrets.PUBLISH_NUGET_ORG }} | |
| CHOCO_API_KEY: ${{ secrets.PUBLISH_CHOCOLATEY_ORG }} | |
| GITHUB_ACCESS_TOKEN: ${{ secrets.GH_ACCESS_CP }} | |
| steps: | |
| - name: ⤵️ Checkout Source | |
| uses: actions/checkout@v7 | |
| with: | |
| fetch-depth: 0 | |
| - name: 🛠️ Setup .NET | |
| uses: actions/setup-dotnet@v6 | |
| with: | |
| dotnet-version: | | |
| 3.1.x | |
| 6.0.x | |
| 7.0.x | |
| 8.0.x | |
| 9.0.x | |
| - name: 🔧 Install dotnet tools | |
| run: dotnet tool restore | |
| - name: 🔨 Build, Test and Package | |
| run: dotnet cake --target=BuildTestAndPackage --configuration=Release #--verbosity=diagnostic | |
| # Upload packages before publishing in case of later failures | |
| - name: 💾 Upload build artifacts | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: NUnitConsole Packages | |
| path: | | |
| packages/*.nupkg | |
| packages/results/ | |
| - name: Publish only if current commit is labeled | |
| run: | | |
| $tag = "$(git describe --tags --long)" | |
| $label = $tag.Substring(0,$tag.LastIndexOf("-", $tag.LastIndexOf("-")-1)) | |
| echo "Most recent label: $label" | |
| $taginfo = $tag.Split("-") | |
| $height = $taginfo[-2] | |
| echo "Number of commits since label: $height" | |
| if ($height -eq "0") | |
| { | |
| dotnet cake --target=Publish --configuration=Release --noBuild --nopush | |
| } | |
| else | |
| { | |
| dotnet cake --target=Publish --configuration=Release --nobuild --nopush | |
| } |