4040
4141 runs-on : ${{ matrix.os }}
4242
43+ permissions :
44+ contents : read
45+
4346 steps :
4447 - name : Clone the repo
4548 uses : actions/checkout@v4
6164 runs-on : windows-latest
6265 needs : build-all-configs
6366
67+ permissions :
68+ contents : read
69+
6470 env :
6571 version_suffix_args : ${{ github.event_name != 'release' && format('--version-suffix "{0}"', inputs.version_suffix_override || format('ci.{0}', github.run_number)) || '' }}
6672
8793 name : build-artifacts
8894 path : ${{ github.workspace }}/artifacts
8995
90- publish-package :
96+ publish-github :
9197 needs : build-package
9298 runs-on : ubuntu-latest
99+
100+ permissions :
101+ packages : write
102+
93103 steps :
94104 - uses : actions/checkout@v4
95105
@@ -101,13 +111,6 @@ jobs:
101111 - name : Download build artifacts
102112 uses : actions/download-artifact@v4
103113
104- - name : Upload release asset
105- if : github.event_name == 'release'
106- run : gh release upload ${{ github.event.release.tag_name }}
107- ${{ github.workspace }}/build-artifacts/packages/*.*nupkg
108- env :
109- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
110-
111114 - name : Authenticate to GitHub registry
112115 run : dotnet nuget add source
113116 " https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json"
@@ -123,9 +126,50 @@ jobs:
123126 --api-key ${{ secrets.GITHUB_TOKEN }}
124127 --skip-duplicate
125128
129+ publish-release :
130+ if : github.event_name == 'release'
131+ needs : build-package
132+ runs-on : ubuntu-latest
133+
134+ permissions :
135+ contents : write
136+ packages : write
137+
138+ steps :
139+ - uses : actions/checkout@v4
140+
141+ - name : Setup .NET
142+ uses : actions/setup-dotnet@v2
143+ with :
144+ dotnet-version : 9.0.x
145+
146+ - name : Download build artifacts
147+ uses : actions/download-artifact@v4
148+
149+ - name : Upload release asset
150+ run : gh release upload ${{ github.event.release.tag_name }}
151+ ${{ github.workspace }}/build-artifacts/packages/*.*nupkg
152+ env :
153+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
154+
155+ publish-nuget :
156+ # Only publish to NuGet.org from the modelcontextprotocol/csharp-sdk repository
157+ if : ${{ github.event_name == 'release' && github.repository == 'modelcontextprotocol/csharp-sdk' }}
158+ needs : build-package
159+ runs-on : ubuntu-latest
160+
161+ steps :
162+ - uses : actions/checkout@v4
163+
164+ - name : Setup .NET
165+ uses : actions/setup-dotnet@v2
166+ with :
167+ dotnet-version : 9.0.x
168+
169+ - name : Download build artifacts
170+ uses : actions/download-artifact@v4
171+
126172 - name : Publish to NuGet.org (Releases only)
127- # Only publish to NuGet.org from the modelcontextprotocol/csharp-sdk repository
128- if : ${{ github.event_name == 'release' && github.repository == 'modelcontextprotocol/csharp-sdk' }}
129173 run : dotnet nuget push
130174 ${{github.workspace}}/build-artifacts/packages/*.nupkg
131175 --source https://api.nuget.org/v3/index.json
0 commit comments