openai/openai-dotnet
Publicmirrored from https://github.com/openai/openai-dotnetAvailable
.github/workflows/main.yml
60lines · modecode
| 1 | name: Build and Test |
| 2 | |
| 3 | on: |
| 4 | workflow_dispatch: |
| 5 | push: |
| 6 | branches: |
| 7 | - main |
| 8 | pull_request: |
| 9 | types: [opened, reopened, synchronize] |
| 10 | |
| 11 | jobs: |
| 12 | build: # Test, pack and publish the Open AI nuget package as a build artifact |
| 13 | runs-on: ubuntu-latest |
| 14 | env: |
| 15 | version_suffix_args: ${{ format('--version-suffix="alpha.{0}"', github.run_number) }} |
| 16 | steps: |
| 17 | - name: Setup .NET |
| 18 | uses: actions/setup-dotnet@v1 |
| 19 | with: |
| 20 | dotnet-version: 8.x |
| 21 | |
| 22 | - name: Checkout code |
| 23 | uses: actions/checkout@v2 |
| 24 | |
| 25 | - name: Build and Pack |
| 26 | run: dotnet pack |
| 27 | --configuration Release |
| 28 | --output "${{github.workspace}}/artifacts/packages" |
| 29 | ${{ env.version_suffix_args }} |
| 30 | |
| 31 | - name: Test |
| 32 | run: dotnet test |
| 33 | --configuration Release |
| 34 | --filter="TestCategory~${{ github.event_name == 'pull_request' && 'Offline' || 'Online' }}" |
| 35 | --logger "trx;LogFileName=${{github.workspace}}/artifacts/test-results/full.trx" |
| 36 | env: |
| 37 | OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} |
| 38 | |
| 39 | - name: Upload artifact |
| 40 | uses: actions/upload-artifact@v2 |
| 41 | with: |
| 42 | name: build-artifacts |
| 43 | path: ${{github.workspace}}/artifacts |
| 44 | |
| 45 | - name: NuGet Autenticate |
| 46 | if: github.event_name != 'pull_request' |
| 47 | run: dotnet nuget add source |
| 48 | "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json" |
| 49 | --name "github" |
| 50 | --username ${{ github.actor }} |
| 51 | --password ${{ secrets.GITHUB_TOKEN }} |
| 52 | --store-password-in-clear-text |
| 53 | |
| 54 | - name: Publish |
| 55 | if: github.event_name != 'pull_request' |
| 56 | run: dotnet nuget push |
| 57 | ${{github.workspace}}/artifacts/packages/*.*nupkg |
| 58 | --source "github" |
| 59 | --api-key ${{ secrets.GITHUB_TOKEN }} |
| 60 | --skip-duplicate |
| 61 | |