|
1 | 1 | name: Publish-to-nuget
|
2 | 2 | on:
|
3 |
| - workflow_run: |
4 |
| - workflows: ["Check-code-quality"] |
5 |
| - branches: ["v[0-9]+.[0-9]+.[0-9]+"] |
6 |
| - types: |
7 |
| - - completed |
| 3 | + push: |
| 4 | + tags: |
| 5 | + - "v[0-9]+.[0-9]+.[0-9]+" |
| 6 | + |
8 | 7 | jobs:
|
| 8 | + build: |
| 9 | + runs-on: ubuntu-latest |
| 10 | + steps: |
| 11 | + - name: Checkout |
| 12 | + uses: actions/checkout@v4 |
| 13 | + - name: Build |
| 14 | + run: dotnet build --configuration Release |
| 15 | + test: |
| 16 | + runs-on: ubuntu-latest |
| 17 | + needs: build |
| 18 | + steps: |
| 19 | + - name: Checkout |
| 20 | + uses: actions/checkout@v4 |
| 21 | + - name: Test |
| 22 | + run: dotnet test --configuration Release |
| 23 | + sonarqube: |
| 24 | + name: sonarqube |
| 25 | + runs-on: ubuntu-latest |
| 26 | + needs: test |
| 27 | + if: ${{ github.event.workflow_run.conclusion == 'success' }} |
| 28 | + steps: |
| 29 | + - name: Set up JDK 17 |
| 30 | + uses: actions/setup-java@v4 |
| 31 | + with: |
| 32 | + distribution: 'microsoft' # See 'Supported distributions' for available options |
| 33 | + java-version: '17' |
| 34 | + - uses: actions/checkout@v4 |
| 35 | + with: |
| 36 | + fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis |
| 37 | + - name: Cache SonarCloud packages |
| 38 | + uses: actions/cache@v4 |
| 39 | + with: |
| 40 | + path: ~\sonar\cache |
| 41 | + key: ${{ runner.os }}-sonar |
| 42 | + restore-keys: ${{ runner.os }}-sonar |
| 43 | + - name: Cache SonarCloud scanner |
| 44 | + id: cache-sonar-scanner |
| 45 | + uses: actions/cache@v4 |
| 46 | + with: |
| 47 | + path: .\.sonar\scanner |
| 48 | + key: ${{ runner.os }}-sonar-scanner |
| 49 | + restore-keys: ${{ runner.os }}-sonar-scanner |
| 50 | + - name: Install SonarCloud scanner |
| 51 | + if: steps.cache-sonar-scanner.outputs.cache-hit != 'true' |
| 52 | + shell: powershell |
| 53 | + run: | |
| 54 | + New-Item -Path .\.sonar\scanner -ItemType Directory |
| 55 | + dotnet tool update dotnet-sonarscanner --tool-path .\.sonar\scanner |
| 56 | + - name: Build and analyze |
| 57 | + env: |
| 58 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any |
| 59 | + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} |
| 60 | + shell: powershell |
| 61 | + run: | |
| 62 | + dotnet tool install --global dotnet-coverage |
| 63 | + .\.sonar\scanner\dotnet-sonarscanner begin /k:"RxTelegram_RxTelegram.Bot" /o:"rxtelegram" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.cs.vscoveragexml.reportsPaths=coverage.xml |
| 64 | + dotnet build --configuration Release |
| 65 | + dotnet-coverage collect 'dotnet test' -f xml -o 'coverage.xml' --settings CodeCoverage.runsettings |
| 66 | + .\.sonar\scanner\dotnet-sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}" |
9 | 67 | publish:
|
10 | 68 | runs-on: ubuntu-latest
|
11 |
| - timeout-minutes: 3 |
| 69 | + needs: sonarqube |
12 | 70 | steps:
|
13 | 71 | - name: Download build result
|
14 | 72 | uses: actions/download-artifact@v4
|
|
20 | 78 | run: dotnet pack --configuration Release /p:Version=${VERSION} --no-build --output .
|
21 | 79 | - name: Push nuget to nuget.org
|
22 | 80 | run: dotnet nuget push RxTelegram.Bot.*.nupkg -k ${{secrets.NUGET_API_KEY}} -s https://api.nuget.org/v3/index.json
|
| 81 | + - name: Publish release |
| 82 | + uses: ghalactic/github-release-from-tag@v5 |
0 commit comments