Skip to content

Commit 22addc1

Browse files
committed
Rewrite nuget packages publishing to individual gated job
1 parent 0cc1573 commit 22addc1

File tree

2 files changed

+48
-9
lines changed

2 files changed

+48
-9
lines changed

.github/Get-BuildInfo.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,4 @@ Write-GitHubVariable "app_version_suffix" $app_version_suffix
5858
Write-GitHubVariable "app_version_full" $app_version_full
5959
Write-GitHubVariable "sign_binaries" $sign_binaries
6060
Write-GitHubVariable "publish_nuget" $publish_nuget
61+
Write-GitHubVariable "nuget_packages_artifact_name" "NetOffice_packages_v$app_version_full"

.github/workflows/release.yml

Lines changed: 47 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ jobs:
2929
RepositoryCommit: '${{ github.sha }}'
3030
Configuration: '${{ matrix.configuration }}'
3131

32+
outputs:
33+
nuget_packages_artifact_name: ${{ steps.build.outputs.nuget_packages_artifact_name }}
34+
3235
steps:
3336
- name: Checkout
3437
uses: actions/checkout@v5
@@ -147,17 +150,52 @@ jobs:
147150
$nupkg = Get-ChildItem -Path '${{ github.workspace}}\dist' -Filter '*.nupkg' | Select-Object -First 1
148151
nuget-cert-extractor --file $nupkg --output '${{ github.workspace}}\dist' --code-signing --author --leaf
149152
150-
- name: Publish packages
151-
if: success() && steps.build.outputs.publish_nuget == 'true'
152-
working-directory: '${{ github.workspace}}\dist'
153-
run: |
154-
dotnet nuget push *.nupkg --api-key $env:NUGET_TOKEN --source https://api.nuget.org/v3/index.json
155-
env:
156-
NUGET_TOKEN: ${{ secrets.NUGET_TOKEN }}
157-
158153
- name: Archive NetOffice packages
159154
if: success()
160155
uses: actions/upload-artifact@v5
161156
with:
162-
name: NetOffice_packages_v${{ steps.build.outputs.app_version_full }}
157+
name: ${{ steps.build.outputs.nuget_packages_artifact_name }}
163158
path: '${{ github.workspace }}\dist'
159+
160+
- name: Archive code signing certificate
161+
if: success() && matrix.configuration == 'Release'
162+
uses: actions/upload-artifact@v5
163+
with:
164+
name: certificate
165+
path: '${{ github.workspace }}/dist/*.cer'
166+
167+
- name: Release documentation
168+
if: matrix.configuration == 'Release'
169+
run: |
170+
'To release the NuGet package, upload the signing certificate to NuGet Gallery via Account Settings: <https://www.nuget.org/account>. ' >> $env:GITHUB_STEP_SUMMARY
171+
'See the `certificate` artifact for the signing certificate file.' >> $env:GITHUB_STEP_SUMMARY
172+
'' >> $env:GITHUB_STEP_SUMMARY
173+
'Approve the `publish` job deployment to the `nuget-gallery` environment when the certificate was added to NuGet Gallery.' >> $env:GITHUB_STEP_SUMMARY
174+
175+
publish:
176+
environment: nuget-gallery
177+
178+
permissions:
179+
id-token: write
180+
181+
needs: release
182+
183+
runs-on: ubuntu-latest
184+
185+
steps:
186+
- name: Download NetOffice packages
187+
uses: actions/download-artifact@v5
188+
with:
189+
name: ${{ needs.release.outputs.nuget_packages_artifact_name }}
190+
191+
- name: Authenticate Nuget Gallery
192+
uses: NuGet/login@v1
193+
id: nuget
194+
with:
195+
user: ${{ secrets.NUGET_TRUSTED_PUBLISHING_USER }}
196+
197+
- name: Publish packages
198+
run: |
199+
dotnet nuget push "*.nupkg" --api-key "$NUGET_API_KEY" --source https://api.nuget.org/v3/index.json
200+
env:
201+
NUGET_API_KEY: ${{ steps.nuget.outputs.NUGET_API_KEY }}

0 commit comments

Comments
 (0)