Add manual workflow dispatch and fix API key validation #4
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
| name: CI/CD Pipeline | |
| on: | |
| push: | |
| branches: [ master ] | |
| pull_request: | |
| branches: [ master ] | |
| release: | |
| types: [ published ] | |
| workflow_dispatch: | |
| inputs: | |
| publish_to_nuget: | |
| description: 'Publish to NuGet.org' | |
| required: false | |
| default: false | |
| type: boolean | |
| jobs: | |
| build-and-test: | |
| runs-on: ubuntu-latest | |
| name: Build and Test | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: '9.0.x' | |
| - name: Run build and test | |
| shell: pwsh | |
| run: ./CI-CD/ci-cd.ps1 -Phase build | |
| - name: Upload artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: nuget-packages | |
| path: ./artifacts/*.nupkg | |
| publish-nuget: | |
| runs-on: ubuntu-latest | |
| name: Publish to NuGet | |
| needs: build-and-test | |
| if: (github.event_name == 'release' && github.event.action == 'published') || (github.event_name == 'workflow_dispatch' && inputs.publish_to_nuget == true) | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: '9.0.x' | |
| - name: Download artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: nuget-packages | |
| path: ./artifacts | |
| - name: Publish to NuGet | |
| shell: pwsh | |
| run: ./CI-CD/ci-cd.ps1 -Phase publish -PublishToNuGet $true | |
| env: | |
| NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }} |