openai/openai-dotnet

Public

mirrored from https://github.com/openai/openai-dotnetAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
copilot/create-responses-client-options-type

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

.github/workflows/release.yml

184lines · modecode

1# This workflow is triggered by new releases and on a daily schedule.
2# It builds, unit tests, live tests and publishes the Open AI NuGet package.
3# For daily runs, the package is published to the GitHub package registry.
4# For releases, the package is published to the NuGet package registry.
5name: Release package
6
7on:
8 release:
9 types: [published]
10 schedule:
11 # run every day at 00:00
12 - cron: '0 0 * * *'
13
14permissions:
15 contents: write
16 packages: write
17
18jobs:
19 build:
20 name: Build
21 runs-on: ubuntu-latest
22 environment: Live Testing
23 env:
24 version_suffix_args: ${{ github.event_name == 'schedule' && format('/p:VersionSuffix="alpha.{0}"', github.run_number) || '' }}
25 steps:
26 - name: Setup .NET 10
27 uses: actions/setup-dotnet@c2fa09f4bde5ebb9d1777cf28262a3eb3db3ced7 # v5.2.0
28 with:
29 dotnet-version: '10.x'
30
31 - name: Setup .NET 9
32 uses: actions/setup-dotnet@c2fa09f4bde5ebb9d1777cf28262a3eb3db3ced7 # v5.2.0
33 with:
34 dotnet-version: '9.x'
35
36 - name: Setup .NET 8
37 uses: actions/setup-dotnet@c2fa09f4bde5ebb9d1777cf28262a3eb3db3ced7 # v5.2.0
38 with:
39 dotnet-version: '8.x'
40
41 - name: Checkout code
42 uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
43
44 - name: Restore tools
45 run: dotnet tool restore --add-source https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-net/nuget/v3/index.json
46
47 # Pack the client NuGet package and include URL back to the repository and release tag
48 - name: Build and pack
49 run: dotnet pack
50 --configuration Release
51 --output "${{ github.workspace }}/artifacts/packages"
52 /p:PackageProjectUrl="${{ github.server_url }}/${{ github.repository }}/tree/${{ github.event.release.tag_name }}"
53 /p:PackageReleaseNotes="${{ github.server_url }}/${{ github.repository }}/blob/${{ github.event.release.tag_name }}/CHANGELOG.md"
54 ${{ env.version_suffix_args }}
55
56 - name: Run unit tests
57 run: dotnet test
58 --configuration Release
59 --logger "trx;LogFileName=${{ github.workspace }}/artifacts/test-results/smoke.trx"
60 ${{ env.version_suffix_args }}
61 -- NUnit.Where="cat == Smoke and cat != Manual"
62
63 - name: Run recorded tests
64 run: dotnet test ./tests/OpenAI.Tests.csproj
65 --configuration Release
66 --logger "trx;LogFilePrefix=live"
67 --results-directory ${{ github.workspace }}/artifacts/test-results
68 ${{ env.version_suffix_args }}
69 -- NUnit.Where="(cat == Chat or cat == Embeddings or cat == Responses) and cat != MPFD"
70 env:
71 CLIENTMODEL_TEST_MODE: Playback
72 CLIENTMODEL_DISABLE_AUTO_RECORDING: true
73
74 - name: Upload artifact
75 uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
76 if: ${{ !cancelled() }}
77 with:
78 name: build-artifacts
79 path: ${{ github.workspace }}/artifacts
80
81 sign:
82 needs: build
83 runs-on: windows-latest # Code signing must run on a Windows agent for Authenticode signing (dll/exe)
84 environment: release # Needed for OIDC subject for releases triggered on release being created.
85 permissions:
86 id-token: write # Required for requesting the JWT
87
88 steps:
89 - name: Download build artifacts
90 uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0
91 with:
92 name: build-artifacts
93 path: ${{ github.workspace }}/build-artifacts
94
95 - name: Setup .NET
96 uses: actions/setup-dotnet@c2fa09f4bde5ebb9d1777cf28262a3eb3db3ced7 # v5.2.0
97 with:
98 dotnet-version: '9.x'
99
100 - name: Install Sign CLI tool
101 run: dotnet tool install --tool-path . --prerelease sign
102
103 - name: 'Az CLI login'
104 uses: azure/login@532459ea530d8321f2fb9bb10d1e0bcf23869a43 # v3.0.0
105 with:
106 client-id: 80125de0-6f58-4f16-bd05-b2fa621d36a5
107 tenant-id: 16076fdc-fcc1-4a15-b1ca-32c9a255900e
108 allow-no-subscriptions: true
109
110 - name: Sign artifacts
111 shell: pwsh
112 run: >
113 ./sign code azure-key-vault
114 **/*.nupkg
115 --base-directory "${{ github.workspace }}/build-artifacts/packages"
116 --publisher-name "OpenAI"
117 --description "OpenAI library for .NET"
118 --description-url "https://github.com/openai/openai-dotnet"
119 --azure-credential-type "azure-cli"
120 --azure-key-vault-url "https://sc-openaisdk.vault.azure.net/"
121 --azure-key-vault-certificate "OpenAISDKSCCert"
122
123 - name: Upload signed artifact
124 uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
125 with:
126 name: build-artifacts-signed
127 path: ${{ github.workspace }}/build-artifacts
128
129 deploy:
130 name: Publish package
131 needs: sign
132 runs-on: ubuntu-latest
133 steps:
134 - name: Checkout code
135 uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
136
137 - name: Download build artifacts
138 uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0
139 with:
140 name: build-artifacts-signed
141 path: ${{ github.workspace }}/build-artifacts
142
143 - name: Upload release asset
144 if: github.event_name == 'release'
145 run: gh release upload ${{ github.event.release.tag_name }}
146 ${{ github.workspace }}/build-artifacts/packages/*.*nupkg
147 env:
148 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
149
150 - name: Update GitHub release notes to point to the changelog
151 if: github.event_name == 'release'
152 run: |
153 gh release edit "${{ github.event.release.tag_name }}" \
154 --notes "See full changelog: ${{ github.server_url }}/${{ github.repository }}/blob/${{ github.event.release.tag_name }}/CHANGELOG.md"
155 env:
156 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
157
158 - name: Setup .NET
159 uses: actions/setup-dotnet@c2fa09f4bde5ebb9d1777cf28262a3eb3db3ced7 # v5.2.0
160 with:
161 dotnet-version: '9.x'
162
163 - name: NuGet authenticate
164 run: dotnet nuget add source
165 "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json"
166 --name "github"
167 --username ${{ github.actor }}
168 --password ${{ secrets.GITHUB_TOKEN }}
169 --store-password-in-clear-text
170
171 - name: Publish package to local feed
172 run: dotnet nuget push
173 ${{ github.workspace }}/build-artifacts/packages/*.nupkg
174 --source "github"
175 --api-key ${{ secrets.GITHUB_TOKEN }}
176 --skip-duplicate
177
178 - name: Publish package to nuget.org
179 if: github.event_name == 'release'
180 run: dotnet nuget push
181 ${{ github.workspace }}/build-artifacts/packages/*.nupkg
182 --source https://api.nuget.org/v3/index.json
183 --api-key ${{ secrets.NUGET_API_KEY }}
184 --skip-duplicate
185