OpenAI-DotNet 7.2.0 #398
Workflow file for this run
This file contains 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: Nuget Publish | |
on: | |
push: | |
branches: | |
- main | |
paths: | |
- OpenAI-DotNet/** | |
- OpenAI-DotNet-Proxy/** | |
pull_request: | |
branches: | |
- '*' | |
paths: | |
- OpenAI-DotNet/** | |
- OpenAI-DotNet-Proxy/** | |
types: | |
- opened | |
- synchronize | |
workflow_dispatch: | |
inputs: | |
dotnet-version: | |
description: ".NET version to use" | |
required: false | |
default: "6.0.x" | |
env: | |
DOTNET_VERSION: ${{ github.event.inputs.dotnet-version || '6.0.x' }} | |
PACKAGE_VERSION: '' | |
jobs: | |
build: | |
if: ${{ !github.event_name == 'pull_request' || !github.event.pull_request.draft }} | |
runs-on: windows-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- uses: actions/setup-dotnet@v3 | |
with: | |
dotnet-version: ${{ env.DOTNET_VERSION }} | |
- uses: microsoft/setup-msbuild@v1 | |
- name: Test Packages | |
run: dotnet test --configuration Release | |
if: ${{ github.ref != 'refs/heads/main' && github.event_name != 'push' }} | |
env: | |
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} | |
OPENAI_ORGANIZATION_ID: ${{ secrets.OPENAI_ORGANIZATION_ID }} | |
- name: Build Pack and Publish NuGet Package | |
run: | | |
$projectPath = "${{ github.workspace }}\OpenAI-DotNet" | |
$proxyProjectPath = "${{ github.workspace }}\OpenAI-DotNet-Proxy" | |
# build all | |
dotnet build --configuration Release | |
# pack OpenAI-DotNet | |
dotnet pack $projectPath --configuration Release --include-symbols | |
$out = "$projectPath\bin\Release" | |
$packagePath = Get-ChildItem -Path $out -File -Include '*.nupkg' -Exclude '*symbols*' -Recurse -ErrorAction SilentlyContinue | |
if ($packagePath) { | |
Write-Host Package path: $packagePath | |
} else { | |
Write-Host Failed to find package at $out | |
exit 1 | |
} | |
# pack OpenAI-DotNet-Proxy | |
dotnet pack $proxyProjectPath --configuration Release --include-symbols | |
$proxyOut = "$proxyProjectPath\bin\Release" | |
$proxyPackagePath = Get-ChildItem -Path $proxyOut -File -Include '*.nupkg' -Exclude '*symbols*' -Recurse -ErrorAction SilentlyContinue | |
if ($proxyPackagePath) { | |
Write-Host Package path: $proxyPackagePath | |
} else { | |
Write-Host Failed to find package at $proxyOut | |
exit 1 | |
} | |
$isRelease = "${{ github.ref == 'refs/heads/main' }}" | |
if ($isRelease -eq 'true') { | |
dotnet nuget push $packagePath.FullName --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate | |
dotnet nuget push $proxyPackagePath.FullName --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate | |
} | |
$version = $packagePath.Name -replace "^OpenAI-DotNet.(.*).nupkg$",'$1' | |
echo "PACKAGE_VERSION=$version" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append | |
shell: pwsh | |
- uses: actions/upload-artifact@v3 | |
if: always() | |
with: | |
name: OpenAI-DotNet.${{ env.PACKAGE_VERSION }} | |
path: | | |
${{ github.workspace }}/OpenAI-DotNet/bin/Release/OpenAI-DotNet.${{ env.PACKAGE_VERSION }}.nupkg | |
${{ github.workspace }}/OpenAI-DotNet/bin/Release/OpenAI-DotNet.${{ env.PACKAGE_VERSION }}.symbols.nupkg | |
${{ github.workspace }}/OpenAI-DotNet/bin/Release/OpenAI-DotNet-Proxy.${{ env.PACKAGE_VERSION }}.nupkg | |
${{ github.workspace }}/OpenAI-DotNet/bin/Release/OpenAI-DotNet-Proxy.${{ env.PACKAGE_VERSION }}.symbols.nupkg | |
if-no-files-found: ignore |