openai/openai-dotnet

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
achandmsft-patch-2

Branches

Tags

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

Clone

HTTPS

Download ZIP

.github/workflows/release.yml

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