|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: {} |
| 5 | + push: |
| 6 | + branches: |
| 7 | + - main |
| 8 | + release: |
| 9 | + types: |
| 10 | + - published |
| 11 | + workflow_dispatch: {} |
| 12 | + |
| 13 | +jobs: |
| 14 | + publish: |
| 15 | + env: |
| 16 | + ASPIRE_ALLOW_UNSECURED_TRANSPORT: true |
| 17 | + DOTNET_CLI_TELEMETRY_OPTOUT: true |
| 18 | + DOTNET_MULTILEVEL_LOOKUP: false |
| 19 | + DOTNET_NOLOGO: true |
| 20 | + DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true |
| 21 | + runs-on: ubuntu-latest |
| 22 | + permissions: |
| 23 | + contents: read |
| 24 | + packages: write |
| 25 | + steps: |
| 26 | + - name: Checkout |
| 27 | + uses: actions/checkout@v4 |
| 28 | + with: |
| 29 | + fetch-depth: 0 |
| 30 | + |
| 31 | + - name: Setup .NET Core SDK 8 |
| 32 | + uses: actions/setup-dotnet@v4 |
| 33 | + with: |
| 34 | + dotnet-version: | |
| 35 | + 8.0.x |
| 36 | +
|
| 37 | + - name: Restore .NET Packages |
| 38 | + run: | |
| 39 | + dotnet workload restore "./Migrator.sln" |
| 40 | + dotnet restore "./Migrator.sln" --locked-mode |
| 41 | +
|
| 42 | + - name: Build .NET Solution |
| 43 | + run: dotnet build "./Migrator.sln" --configuration Release --no-restore |
| 44 | + |
| 45 | + - name: Test .NET Solution |
| 46 | + run: > |
| 47 | + dotnet test "./Migrator.sln" |
| 48 | + --collect:"XPlat Code Coverage" --no-build --verbosity normal --configuration Release |
| 49 | + --logger console --logger GitHubActions --logger "trx;LogFilePrefix=test-results" |
| 50 | + -property:DeterministicSourcePaths=true -property:IncludeTestAssembly=true |
| 51 | + --results-directory '${{ github.workspace }}/reports/coverage/' --blame |
| 52 | + -- |
| 53 | + RunConfiguration.CollectSourceInformation=true |
| 54 | + timeout-minutes: 5 |
| 55 | + |
| 56 | + - name: Upload Test Artifacts |
| 57 | + uses: actions/upload-artifact@v4 |
| 58 | + if: success() || failure() |
| 59 | + with: |
| 60 | + name: test-results |
| 61 | + path: "**/test-results*.trx" |
| 62 | + |
| 63 | + - name: Pack .NET Solution |
| 64 | + run: dotnet pack "./Migrator.sln" --configuration Release --no-build --output pack/ |
| 65 | + if: ${{ github.event_name == 'release' && github.ref_type == 'tag' || github.event.release.tag_name }} |
| 66 | + |
| 67 | + - name: Publish .NET Solution to GitHub Packages |
| 68 | + continue-on-error: true |
| 69 | + run: dotnet nuget push pack/*.nupkg --api-key ${{ secrets.GITHUB_TOKEN }} --source "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json" |
| 70 | + if: ${{ github.event_name == 'release' && github.ref_type == 'tag' || github.event.release.tag_name }} |
| 71 | + |
| 72 | + - name: Store .NET Package |
| 73 | + uses: actions/upload-artifact@v4 |
| 74 | + with: |
| 75 | + name: nuget |
| 76 | + if-no-files-found: error |
| 77 | + retention-days: 7 |
| 78 | + path: pack/*.nupkg |
| 79 | + if: ${{ github.event_name == 'release' && github.ref_type == 'tag' || github.event.release.tag_name }} |
| 80 | + |
| 81 | + - name: Publish .NET Solution to NuGet.org |
| 82 | + env: |
| 83 | + apikey: ${{ secrets.NUGET_ORG_KEY }} |
| 84 | + continue-on-error: true |
| 85 | + run: dotnet nuget push pack/*.nupkg --api-key ${{ secrets.NUGET_ORG_KEY }} --source nuget |
| 86 | + if: ${{ env.apikey != '' && github.event_name == 'release' && github.ref_type == 'tag' || github.event.release.tag_name }} |
0 commit comments