|
| 1 | +name: All packages build |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ main ] |
| 6 | + pull_request: |
| 7 | + branches: |
| 8 | + - '**/*' |
| 9 | + |
| 10 | +jobs: |
| 11 | + build: |
| 12 | + |
| 13 | + runs-on: ubuntu-latest |
| 14 | + permissions: |
| 15 | + packages: write |
| 16 | + |
| 17 | + steps: |
| 18 | + - uses: actions/checkout@v4 |
| 19 | + - uses: ./.github/workflows/parts/cache/ |
| 20 | + |
| 21 | + - name: Decode the Signing Key |
| 22 | + # Generated via powershell: `[System.Convert]::ToBase64String([System.IO.File]::ReadAllBytes('.\Refactoring.snk')) | Set-Clipboard` and saved to GitHub Secrets SIGNING_KEY |
| 23 | + run: | |
| 24 | + if [ -n "${{ secrets.SIGNING_KEY }}" ]; then |
| 25 | + echo "${{ secrets.SIGNING_KEY }}" | base64 --decode > ./Refactoring.snk |
| 26 | + fi |
| 27 | +
|
| 28 | + ########### |
| 29 | + # BUILD |
| 30 | + - name: Restore dependencies |
| 31 | + run: dotnet restore |
| 32 | + - name: Build |
| 33 | + run: | |
| 34 | + if [[ $VERSION_SUFFIX ]]; then |
| 35 | + VERSION_SUFFIX_PARAM="--version-suffix sha.$VERSION_SUFFIX" |
| 36 | + else |
| 37 | + VERSION_SUFFIX_PARAM='' |
| 38 | + fi |
| 39 | + dotnet build --no-restore --configuration Release ${VERSION_SUFFIX_PARAM} |
| 40 | + env: |
| 41 | + VERSION_SUFFIX: ${{ github.ref != 'refs/heads/main' && github.sha || '' }} |
| 42 | + |
| 43 | + ########### |
| 44 | + # TEST |
| 45 | + - name: Test |
| 46 | + run: | |
| 47 | + if [[ $VERSION_SUFFIX ]]; then |
| 48 | + VERSION_SUFFIX_PARAM="-p:VersionSuffix=sha.$VERSION_SUFFIX" |
| 49 | + else |
| 50 | + VERSION_SUFFIX_PARAM='' |
| 51 | + fi |
| 52 | + dotnet test --verbosity normal ${VERSION_SUFFIX_PARAM} --configuration Release --collect:"XPlat Code Coverage" |
| 53 | + env: |
| 54 | + VERSION_SUFFIX: ${{ github.ref != 'refs/heads/main' && github.sha || '' }} |
| 55 | + - name: 'Upload Code Coverage' |
| 56 | + uses: actions/upload-artifact@v4 |
| 57 | + with: |
| 58 | + name: code-coverage |
| 59 | + path: ./lib/*/TestResults/*/coverage.cobertura.xml |
| 60 | + retention-days: 7 |
| 61 | + # - name: Record code coverage |
| 62 | + # uses: 5monkeys/cobertura-action@master |
| 63 | + # with: |
| 64 | + # path: ./lib/*/TestResults/*/coverage.cobertura.xml |
| 65 | + # repo_token: ${{ secrets.GITHUB_TOKEN }} |
| 66 | + # minimum_coverage: 90 |
| 67 | + # fail_below_threshold: false |
| 68 | + |
| 69 | + ########### |
| 70 | + # PUBLISH |
| 71 | + - name: Publish NuGet packages to GitHub registry if new version number |
| 72 | + if: ${{ github.ref != 'refs/heads/main' }} |
| 73 | + run: dotnet nuget push ./artifacts/package/release/*.nupkg -k ${GITHUB_TOKEN} -s https://nuget.pkg.github.com/$GITHUB_REPOSITORY_OWNER/index.json --skip-duplicate --no-symbols |
| 74 | + continue-on-error: true # Dependabot and other outside contributors can't push to our GitHub packages |
| 75 | + env: |
| 76 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 77 | + - name: Publish NuGet packages to NuGet registry if new version number |
| 78 | + if: ${{ github.ref == 'refs/heads/main' }} |
| 79 | + run: dotnet nuget push ./artifacts/package/release/*.nupkg -k ${NUGET_API_KEY} -s https://api.nuget.org/v3/index.json --skip-duplicate --no-symbols |
| 80 | + env: |
| 81 | + NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }} |
0 commit comments