openai/openai-dotnet

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
copilot/customize-openairesponsescontext-attribute

Branches

Tags

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

Clone

HTTPS

Download ZIP

.github/workflows/release.yml

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