|
| 1 | +name: Build |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ main ] |
| 6 | + tags: [ 'v[0-9]+.[0-9]+.[0-9]+*' ] |
| 7 | + |
| 8 | +jobs: |
| 9 | + unit-tests: |
| 10 | + name: "Unit tests" |
| 11 | + strategy: |
| 12 | + matrix: |
| 13 | + os: [ ubuntu-latest, windows-latest, macos-latest ] |
| 14 | + runs-on: ${{ matrix.os }} |
| 15 | + steps: |
| 16 | + - uses: actions/checkout@v4 |
| 17 | + with: |
| 18 | + fetch-depth: 0 |
| 19 | + - name: Setup .NET SDKs |
| 20 | + uses: actions/setup-dotnet@v4 |
| 21 | + with: |
| 22 | + dotnet-version: | |
| 23 | + 6.0.x |
| 24 | + 7.0.x |
| 25 | + 8.0.x |
| 26 | + 9.0.x |
| 27 | + - name: Run unit tests (windows) |
| 28 | + if: matrix.os == 'windows-latest' |
| 29 | + run: ./build.ps1 CodeCoverage |
| 30 | + - name: Run unit tests (ubuntu|macos) |
| 31 | + if: matrix.os != 'windows-latest' |
| 32 | + run: ./build.sh CodeCoverage |
| 33 | + - name: Upload artifacts |
| 34 | + if: always() |
| 35 | + uses: actions/upload-artifact@v4 |
| 36 | + with: |
| 37 | + name: ${{ runner.os }}-artifacts |
| 38 | + path: | |
| 39 | + ./Artifacts/* |
| 40 | + ./TestResults/*.trx |
| 41 | + |
| 42 | + api-tests: |
| 43 | + name: "API tests" |
| 44 | + runs-on: ubuntu-latest |
| 45 | + env: |
| 46 | + DOTNET_NOLOGO: true |
| 47 | + steps: |
| 48 | + - uses: actions/checkout@v4 |
| 49 | + with: |
| 50 | + fetch-depth: 0 |
| 51 | + - name: Setup .NET SDKs |
| 52 | + uses: actions/setup-dotnet@v4 |
| 53 | + with: |
| 54 | + dotnet-version: | |
| 55 | + 6.0.x |
| 56 | + 7.0.x |
| 57 | + 8.0.x |
| 58 | + 9.0.x |
| 59 | + - name: API checks |
| 60 | + run: ./build.sh ApiChecks |
| 61 | + - name: Upload artifacts |
| 62 | + if: always() |
| 63 | + uses: actions/upload-artifact@v4 |
| 64 | + with: |
| 65 | + name: API-tests |
| 66 | + path: | |
| 67 | + ./Artifacts/* |
| 68 | + ./TestResults/*.trx |
| 69 | + |
| 70 | + static-code-analysis: |
| 71 | + name: "Static code analysis" |
| 72 | + runs-on: ubuntu-latest |
| 73 | + env: |
| 74 | + REPORTGENERATOR_LICENSE: ${{ secrets.REPORTGENERATOR_LICENSE }} |
| 75 | + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} |
| 76 | + DOTNET_NOLOGO: true |
| 77 | + steps: |
| 78 | + - uses: actions/checkout@v4 |
| 79 | + with: |
| 80 | + fetch-depth: 0 |
| 81 | + - name: Setup .NET SDKs |
| 82 | + uses: actions/setup-dotnet@v4 |
| 83 | + with: |
| 84 | + dotnet-version: | |
| 85 | + 6.0.x |
| 86 | + 7.0.x |
| 87 | + 8.0.x |
| 88 | + 9.0.x |
| 89 | + - name: Run sonarcloud analysis |
| 90 | + run: ./build.sh CodeAnalysis |
| 91 | + |
| 92 | + publish-test-results: |
| 93 | + name: "Publish Tests Results" |
| 94 | + needs: [ api-tests, unit-tests ] |
| 95 | + runs-on: ubuntu-latest |
| 96 | + permissions: |
| 97 | + checks: write |
| 98 | + pull-requests: write |
| 99 | + if: always() |
| 100 | + steps: |
| 101 | + - name: Download Artifacts |
| 102 | + uses: actions/download-artifact@v4 |
| 103 | + with: |
| 104 | + path: artifacts |
| 105 | + - name: Publish Test Results |
| 106 | + uses: EnricoMi/publish-unit-test-result-action@v2 |
| 107 | + with: |
| 108 | + comment_mode: always |
| 109 | + files: "artifacts/**/**/*.trx" |
| 110 | + |
| 111 | + pack: |
| 112 | + name: "Pack" |
| 113 | + runs-on: ubuntu-latest |
| 114 | + needs: [ publish-test-results, static-code-analysis ] |
| 115 | + env: |
| 116 | + DOTNET_NOLOGO: true |
| 117 | + steps: |
| 118 | + - uses: actions/checkout@v4 |
| 119 | + with: |
| 120 | + fetch-depth: 0 |
| 121 | + - name: Setup .NET SDKs |
| 122 | + uses: actions/setup-dotnet@v4 |
| 123 | + with: |
| 124 | + dotnet-version: | |
| 125 | + 6.0.x |
| 126 | + 7.0.x |
| 127 | + 8.0.x |
| 128 | + 9.0.x |
| 129 | + - name: Pack nuget packages |
| 130 | + run: ./build.sh Pack |
| 131 | + - name: Upload packages |
| 132 | + if: always() |
| 133 | + uses: actions/upload-artifact@v4 |
| 134 | + with: |
| 135 | + path: Artifacts/Packages |
| 136 | + name: Packages |
| 137 | + |
| 138 | + push: |
| 139 | + name: "Push" |
| 140 | + if: ${{ startsWith(github.ref, 'refs/tags/v') }} |
| 141 | + runs-on: macos-latest |
| 142 | + environment: production |
| 143 | + needs: [ pack ] |
| 144 | + permissions: |
| 145 | + contents: write |
| 146 | + steps: |
| 147 | + - name: Download packages |
| 148 | + uses: actions/download-artifact@v4 |
| 149 | + with: |
| 150 | + name: Packages |
| 151 | + path: Artifacts/Packages |
| 152 | + - name: Publish |
| 153 | + run: | |
| 154 | + echo "Found the following packages to push:" |
| 155 | + search_dir=Artifacts/Packages |
| 156 | + for entry in Artifacts/Packages/*.nupkg |
| 157 | + do |
| 158 | + echo "- $entry" |
| 159 | + done |
| 160 | + for entry in Artifacts/Packages/*.nupkg |
| 161 | + do |
| 162 | + nuget push $entry -Source 'https://api.nuget.org/v3/index.json' -ApiKey ${{secrets.NUGET_API_KEY}} -SkipDuplicate |
| 163 | + done |
| 164 | + - name: Check pre-release |
| 165 | + id: check-pre-release |
| 166 | + run: | |
| 167 | + if [[ ${{ github.event.ref }} =~ ^refs/tags/v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then |
| 168 | + echo "release=true" >> $GITHUB_OUTPUT |
| 169 | + fi |
| 170 | + - name: Create GitHub release |
| 171 | + if: steps.check-pre-release.outputs.release == 'true' |
| 172 | + continue-on-error: true |
| 173 | + uses: softprops/action-gh-release@v2 |
| 174 | + with: |
| 175 | + name: ${{ steps.tag.outputs.release_version }} |
| 176 | + tag_name: ${{ steps.tag.outputs.release_version }} |
| 177 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 178 | + generate_release_notes: true |
| 179 | + |
| 180 | + finalize-release: |
| 181 | + name: "Finalize release" |
| 182 | + if: startsWith(github.ref, 'refs/tags/v') |
| 183 | + runs-on: ubuntu-latest |
| 184 | + needs: [ push ] |
| 185 | + permissions: |
| 186 | + contents: read |
| 187 | + issues: write |
| 188 | + pull-requests: write |
| 189 | + steps: |
| 190 | + - name: Check pre-release |
| 191 | + id: check-pre-release |
| 192 | + run: | |
| 193 | + if [[ ${{ github.event.ref }} =~ ^refs/tags/v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then |
| 194 | + echo "release=true" >> $GITHUB_OUTPUT |
| 195 | + fi |
| 196 | + - name: Comment relevant issues and pull requests |
| 197 | + if: steps.check-pre-release.outputs.release == 'true' |
| 198 | + continue-on-error: true |
| 199 | + uses: apexskier/github-release-commenter@v1.3.6 |
| 200 | + with: |
| 201 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 202 | + comment-template: | |
| 203 | + This is addressed in release {release_link}. |
| 204 | + label-template: | |
| 205 | + state: released |
| 206 | + skip-label: | |
| 207 | + state: released |
0 commit comments