Skip to content

Commit fae2568

Browse files
committed
Rewrite nuget packages publishing to individual gated job
1 parent b01df84 commit fae2568

File tree

2 files changed

+50
-9
lines changed

2 files changed

+50
-9
lines changed

.github/Get-BuildInfo.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,4 @@ Write-GitHubVariable "app_version_suffix" $app_version_suffix
6363
Write-GitHubVariable "app_version_full" $app_version_full
6464
Write-GitHubVariable "sign_binaries" $sign_binaries
6565
Write-GitHubVariable "publish_nuget" $publish_nuget
66+
Write-GitHubVariable "nuget_packages_artifact_name" "NetOffice_packages_v$app_version_full"

.github/workflows/release.yml

Lines changed: 49 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ jobs:
3131
RepositoryCommit: '${{ github.sha }}'
3232
Configuration: '${{ matrix.configuration }}'
3333

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

0 commit comments

Comments
 (0)