Skip to content

Commit afd8642

Browse files
authored
Add signing job before publishing
1 parent aa0baf8 commit afd8642

File tree

1 file changed

+59
-2
lines changed

1 file changed

+59
-2
lines changed

.github/workflows/release.yml

Lines changed: 59 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,16 +69,73 @@ jobs:
6969
name: build-artifacts
7070
path: ${{ github.workspace }}/artifacts
7171

72+
sign:
73+
needs: build
74+
runs-on: windows-latest # Code signing must run on a Windows agent for Authenticode signing (dll/exe)
75+
if: github.event_name == 'release'
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@v4
83+
with:
84+
name: build-artifacts
85+
path: ${{ github.workspace }}/build-artifacts
86+
87+
# .NET is required on the agent for the tool to run
88+
- name: Setup .NET
89+
uses: actions/setup-dotnet@v3
90+
with:
91+
dotnet-version: '9.x'
92+
93+
# Install the code signing tool
94+
- name: Install Sign CLI tool
95+
run: dotnet tool install --tool-path . --prerelease sign
96+
97+
# Login to Azure using a ServicePrincipal configured to authenticate agaist a GitHub Action
98+
- name: 'Az CLI login'
99+
uses: azure/login@v2
100+
with:
101+
allow-no-subscriptions: true
102+
client-id: 80125de0-6f58-4f16-bd05-b2fa621d36a5
103+
tenant-id: 16076fdc-fcc1-4a15-b1ca-32c9a255900e
104+
subscription-id: 997e7c30-fd83-4b3d-bcf5-492e194f9b98
105+
106+
# Run the signing command
107+
- name: Sign artifacts
108+
shell: pwsh
109+
run: >
110+
./sign code azure-key-vault
111+
**/*.nupkg
112+
--base-directory "${{ github.workspace }}/build-artifacts/packages"
113+
--publisher-name "OpenAI"
114+
--description "OpenAI SDK for .NET"
115+
--description-url "https://github.com/openai/openai-dotnet"
116+
--azure-key-vault-managed-identity true
117+
--azure-key-vault-url "https://sc-openaisdk.vault.azure.net/"
118+
--azure-key-vault-certificate "OpenAISDKSCCert"
119+
120+
- name: Upload signed artifact
121+
uses: actions/upload-artifact@v4
122+
with:
123+
name: build-artifacts-signed
124+
path: ${{ github.workspace }}/artifacts
125+
72126
deploy:
73127
name: Publish Package
74-
needs: build
128+
needs: sign
75129
runs-on: ubuntu-latest
76130
steps:
77131
- name: Checkout code
78132
uses: actions/checkout@v2
79133

80134
- name: Download build artifacts
81135
uses: actions/download-artifact@v4
136+
with:
137+
name: build-artifacts-signed
138+
path: ${{ github.workspace }}/build-artifacts
82139

83140
- name: Upload release asset
84141
if: github.event_name == 'release'
@@ -114,4 +171,4 @@ jobs:
114171
${{ github.workspace }}/build-artifacts/packages/*.nupkg
115172
--source https://api.nuget.org/v3/index.json
116173
--api-key ${{ secrets.NUGET_API_KEY }}
117-
--skip-duplicate
174+
--skip-duplicate

0 commit comments

Comments
 (0)