openai/openai-dotnet

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
copilot/update-dotnet-version-to-10

Branches

Tags

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

Clone

HTTPS

Download ZIP

.github/workflows/release.yml

183lines · 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@v5
28 with:
29 dotnet-version: '10.x'
30
31 - name: Setup .NET 9
32 uses: actions/setup-dotnet@v5
33 with:
34 dotnet-version: '9.x'
35
36 - name: Setup .NET 8
37 uses: actions/setup-dotnet@v5
38 with:
39 dotnet-version: '8.x'
40
41 - name: Checkout code
42 uses: actions/checkout@v6
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 --filter="TestCategory=Smoke&TestCategory!=Manual"
60 --logger "trx;LogFileName=${{ github.workspace }}/artifacts/test-results/smoke.trx"
61 ${{ env.version_suffix_args }}
62
63 - name: Run recorded tests
64 run: dotnet test ./tests/OpenAI.Tests.csproj
65 --configuration Release
66 --filter="(TestCategory=Chat|TestCategory=Embeddings|TestCategory=Responses)&TestCategory!=MPFD"
67 --logger "trx;LogFilePrefix=live"
68 --results-directory ${{ github.workspace }}/artifacts/test-results
69 ${{ env.version_suffix_args }}
70 env:
71 OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
72
73 - name: Upload artifact
74 uses: actions/upload-artifact@v6
75 if: ${{ !cancelled() }}
76 with:
77 name: build-artifacts
78 path: ${{ github.workspace }}/artifacts
79
80 sign:
81 needs: build
82 runs-on: windows-latest # Code signing must run on a Windows agent for Authenticode signing (dll/exe)
83 environment: release # Needed for OIDC subject for releases triggered on release being created.
84 permissions:
85 id-token: write # Required for requesting the JWT
86
87 steps:
88 - name: Download build artifacts
89 uses: actions/download-artifact@v7
90 with:
91 name: build-artifacts
92 path: ${{ github.workspace }}/build-artifacts
93
94 - name: Setup .NET
95 uses: actions/setup-dotnet@v5
96 with:
97 dotnet-version: '9.x'
98
99 - name: Install Sign CLI tool
100 run: dotnet tool install --tool-path . --prerelease sign
101
102 - name: 'Az CLI login'
103 uses: azure/login@v2
104 with:
105 client-id: 80125de0-6f58-4f16-bd05-b2fa621d36a5
106 tenant-id: 16076fdc-fcc1-4a15-b1ca-32c9a255900e
107 allow-no-subscriptions: true
108
109 - name: Sign artifacts
110 shell: pwsh
111 run: >
112 ./sign code azure-key-vault
113 **/*.nupkg
114 --base-directory "${{ github.workspace }}/build-artifacts/packages"
115 --publisher-name "OpenAI"
116 --description "OpenAI library for .NET"
117 --description-url "https://github.com/openai/openai-dotnet"
118 --azure-credential-type "azure-cli"
119 --azure-key-vault-url "https://sc-openaisdk.vault.azure.net/"
120 --azure-key-vault-certificate "OpenAISDKSCCert"
121
122 - name: Upload signed artifact
123 uses: actions/upload-artifact@v6
124 with:
125 name: build-artifacts-signed
126 path: ${{ github.workspace }}/build-artifacts
127
128 deploy:
129 name: Publish package
130 needs: sign
131 runs-on: ubuntu-latest
132 steps:
133 - name: Checkout code
134 uses: actions/checkout@v6
135
136 - name: Download build artifacts
137 uses: actions/download-artifact@v7
138 with:
139 name: build-artifacts-signed
140 path: ${{ github.workspace }}/build-artifacts
141
142 - name: Upload release asset
143 if: github.event_name == 'release'
144 run: gh release upload ${{ github.event.release.tag_name }}
145 ${{ github.workspace }}/build-artifacts/packages/*.*nupkg
146 env:
147 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
148
149 - name: Update GitHub release notes to point to the changelog
150 if: github.event_name == 'release'
151 run: |
152 gh release edit "${{ github.event.release.tag_name }}" \
153 --notes "See full changelog: ${{ github.server_url }}/${{ github.repository }}/blob/${{ github.event.release.tag_name }}/CHANGELOG.md"
154 env:
155 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
156
157 - name: Setup .NET
158 uses: actions/setup-dotnet@v5
159 with:
160 dotnet-version: '9.x'
161
162 - name: NuGet authenticate
163 run: dotnet nuget add source
164 "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json"
165 --name "github"
166 --username ${{ github.actor }}
167 --password ${{ secrets.GITHUB_TOKEN }}
168 --store-password-in-clear-text
169
170 - name: Publish package to local feed
171 run: dotnet nuget push
172 ${{ github.workspace }}/build-artifacts/packages/*.nupkg
173 --source "github"
174 --api-key ${{ secrets.GITHUB_TOKEN }}
175 --skip-duplicate
176
177 - name: Publish package to nuget.org
178 if: github.event_name == 'release'
179 run: dotnet nuget push
180 ${{ github.workspace }}/build-artifacts/packages/*.nupkg
181 --source https://api.nuget.org/v3/index.json
182 --api-key ${{ secrets.NUGET_API_KEY }}
183 --skip-duplicate
184