Apply convention faithlife-dotnet-library-workflow (#105) #11
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
| # DO NOT EDIT: generated by Faithlife/CodingGuidelines/conventions/faithlife-dotnet-library-workflow | |
| name: Continuous Integration | |
| on: | |
| push: | |
| branches: [master] | |
| tags-ignore: ['**'] | |
| pull_request: | |
| workflow_dispatch: | |
| env: | |
| DOTNET_NOLOGO: 1 | |
| DOTNET_CLI_TELEMETRY_OPTOUT: 1 | |
| defaults: | |
| run: | |
| shell: pwsh | |
| permissions: | |
| contents: write | |
| id-token: write | |
| jobs: | |
| build-matrix: | |
| name: Build ${{ matrix.os }} | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest, windows-latest, macos-latest] | |
| steps: | |
| - name: Check out code | |
| uses: actions/checkout@v6 | |
| - name: Install .NET | |
| uses: actions/setup-dotnet@v5 | |
| - name: Restore | |
| run: .\build.ps1 restore | |
| - name: Build | |
| run: .\build.ps1 build --skip restore | |
| - name: Test | |
| run: .\build.ps1 test --skip build | |
| - name: Package | |
| run: .\build.ps1 package --skip test | |
| - name: Upload packages | |
| if: matrix.os == 'windows-latest' | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: nuget-packages | |
| path: release/*.nupkg | |
| if-no-files-found: error | |
| build: | |
| name: Build | |
| runs-on: ubuntu-latest | |
| needs: build-matrix | |
| if: ${{ always() }} | |
| steps: | |
| - name: Build failed | |
| if: ${{ needs.build-matrix.result != 'success' }} | |
| run: Write-Host "Build failed."; exit 1 | |
| - name: Build succeeded | |
| if: ${{ needs.build-matrix.result == 'success' }} | |
| run: Write-Host "Build succeeded." | |
| publish: | |
| name: Publish | |
| runs-on: windows-latest | |
| needs: build | |
| if: github.repository_owner == 'Faithlife' && github.ref == 'refs/heads/master' | |
| steps: | |
| - name: Check out code | |
| uses: actions/checkout@v6 | |
| - name: Install .NET | |
| uses: actions/setup-dotnet@v5 | |
| - name: Download packages | |
| uses: actions/download-artifact@v8 | |
| with: | |
| name: nuget-packages | |
| path: release | |
| - name: Log in to NuGet | |
| uses: NuGet/login@v1 | |
| id: nuget-login | |
| with: | |
| user: bgrainger | |
| - name: Publish | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| NUGET_API_KEY: ${{ steps.nuget-login.outputs.NUGET_API_KEY }} | |
| run: .\build.ps1 publish --skip package --trigger publish-nuget-output |