Skip to content

Commit fefd4d3

Browse files
authored
Modernize release workflow for v1.9.x releases (#443)
To continue releasing bugfixes in the `v1.9` train the `release` workflow is modernized with support for Azure Trusted Signing and NuGet Trusted Publishing. The workflow will use federated OIDC logins to Azure and NuGet to minimize secret tokens management. The `nuget-gallery` environment is gated by manual approval, so the second part of the release workflow will run only after the certificate was uploaded to NuGet Gallyer account.
2 parents 7801b11 + 22addc1 commit fefd4d3

File tree

5 files changed

+121
-54
lines changed

5 files changed

+121
-54
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/labels.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
labels:
1515
runs-on: ubuntu-latest
1616
steps:
17-
- uses: actions/checkout@v3
18-
- uses: gitlabels/gitlabels@v1
17+
- uses: actions/checkout@v5
18+
- uses: gitlabels/gitlabels@v2
1919
env:
2020
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/release.yml

Lines changed: 111 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,13 @@ on:
66
- 'v*.*.*'
77

88
permissions:
9+
id-token: write
910
contents: read
1011

1112
jobs:
1213
release:
14+
environment: production
15+
1316
runs-on: windows-2022
1417

1518
strategy:
@@ -26,35 +29,38 @@ jobs:
2629
RepositoryCommit: '${{ github.sha }}'
2730
Configuration: '${{ matrix.configuration }}'
2831

32+
outputs:
33+
nuget_packages_artifact_name: ${{ steps.build.outputs.nuget_packages_artifact_name }}
34+
2935
steps:
3036
- name: Checkout
31-
uses: actions/checkout@v3
37+
uses: actions/checkout@v5
3238

3339
- name: Setup dotnet
34-
uses: actions/setup-dotnet@v3
40+
uses: actions/setup-dotnet@v5
3541
with:
36-
dotnet-version: '7.0.201'
42+
dotnet-version: 8
3743

3844
- name: Setup MSBuild
39-
uses: microsoft/setup-msbuild@v1.1
45+
uses: microsoft/setup-msbuild@v2
4046

4147
- name: Cache dotnet tools
42-
uses: actions/cache@v3
48+
uses: actions/cache@v4
4349
id: cache-dotnettools
4450
with:
4551
path: ~/.dotnet/tools
4652
key: dotnettools
4753

48-
- name: Setup AzureSignTool
54+
- name: Setup dotnet sign tool
4955
if: steps.cache-dotnettools.outputs.cache-hit != 'true'
50-
run: dotnet tool install --verbosity minimal --global azuresigntool --version 3.0.0
56+
run: dotnet tool install --verbosity minimal --global sign --version 0.9.1-beta.25379.1
5157

52-
- name: Setup NuGetKeyVaultSignTool
58+
- name: Setup Knapcode.CertificateExtractor tool
5359
if: steps.cache-dotnettools.outputs.cache-hit != 'true'
54-
run: dotnet tool install --verbosity minimal --global NuGetKeyVaultSignTool --version 3.2.2
60+
run: dotnet tool install --verbosity minimal --global Knapcode.CertificateExtractor --version 0.1.1
5561

5662
- name: Cache packages
57-
uses: actions/cache@v3
63+
uses: actions/cache@v4
5864
with:
5965
path: ~/.nuget/packages
6066
key: NetOffice-nuget-${{ hashFiles('**/packages.lock.json') }}
@@ -77,59 +83,119 @@ jobs:
7783
$content = $content.Replace('${{ github.workspace }}', '..')
7884
$content | Set-Content obj/signlist.txt
7985
86+
- name: azure login
87+
uses: azure/login@v2
88+
with:
89+
client-id: ${{ secrets.TRUSTED_SIGNING_CLIENT_ID }}
90+
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
91+
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
92+
8093
- name: Sign NetOffice libraries
8194
if: success() && steps.build.outputs.sign_binaries == 'true'
82-
uses: azure/trusted-signing-action@v0.3.19
95+
uses: azure/trusted-signing-action@v0.5.10
8396
with:
84-
azure-tenant-id: ${{ secrets.KEYVAULT_TENANT_ID }}
85-
azure-client-id: ${{ secrets.KEYVAULT_CLIENT_ID }}
86-
azure-client-secret: ${{ secrets.KEYVAULT_CLIENT_SECRET }}
87-
endpoint: ${{ vars.KEYVAULT_ENDPOINT }}
88-
trusted-signing-account-name: ${{ vars.KEYVAULT_ACCOUNT_NAME }}
89-
certificate-profile-name: ${{ secrets.KEYVAULT_CERTIFICATE_PROFILE }}
90-
files-catalog: '${{ github.workspace }}/obj/signlist.txt'
91-
file-digest: SHA256
92-
timestamp-rfc3161: http://timestamp.acs.microsoft.com
93-
timestamp-digest: SHA256
97+
endpoint: ${{ secrets.TRUSTED_SIGNING_ENDPOINT }}
98+
trusted-signing-account-name: ${{ secrets.TRUSTED_SIGNING_ACCOUNT_NAME }}
99+
certificate-profile-name: ${{ secrets.TRUSTED_SIGNING_CERTIFICATE_PROFILE }}
100+
files-catalog: '${{ github.workspace }}/obj/signlist.txt'
101+
files: |
102+
${{ github.workspace }}/Source/ClientApplication/bin/${{ matrix.configuration }}/AccessApi.dll
103+
${{ github.workspace }}/Source/ClientApplication/bin/${{ matrix.configuration }}/ADODBApi.dll
104+
${{ github.workspace }}/Source/ClientApplication/bin/${{ matrix.configuration }}/DAOApi.dll
105+
${{ github.workspace }}/Source/ClientApplication/bin/${{ matrix.configuration }}/ExcelApi.dll
106+
${{ github.workspace }}/Source/ClientApplication/bin/${{ matrix.configuration }}/MSComctlLibApi.dll
107+
${{ github.workspace }}/Source/ClientApplication/bin/${{ matrix.configuration }}/MSDATASRCApi.dll
108+
${{ github.workspace }}/Source/ClientApplication/bin/${{ matrix.configuration }}/NetOffice.dll
109+
${{ github.workspace }}/Source/ClientApplication/bin/${{ matrix.configuration }}/OfficeApi.dll
110+
${{ github.workspace }}/Source/ClientApplication/bin/${{ matrix.configuration }}/OfficeApi.Extensions.dll
111+
${{ github.workspace }}/Source/ClientApplication/bin/${{ matrix.configuration }}/OutlookApi.dll
112+
${{ github.workspace }}/Source/ClientApplication/bin/${{ matrix.configuration }}/OWC10Api.dll
113+
${{ github.workspace }}/Source/ClientApplication/bin/${{ matrix.configuration }}/PowerPointApi.dll
114+
${{ github.workspace }}/Source/ClientApplication/bin/${{ matrix.configuration }}/VBIDEApi.dll
115+
${{ github.workspace }}/Source/ClientApplication/bin/${{ matrix.configuration }}/WordApi.dll
116+
file-digest: SHA256
117+
timestamp-rfc3161: http://timestamp.acs.microsoft.com
118+
timestamp-digest: SHA256
94119

95120
- name: Archive NetOffice binaries
96-
uses: actions/upload-artifact@v3
121+
uses: actions/upload-artifact@v5
97122
with:
98123
name: NetOffice_binaries_v${{ steps.build.outputs.app_version_full }}_${{ matrix.configuration }}
99124
path: '${{ github.workspace }}\Source\ClientApplication\bin\${{ matrix.configuration }}'
100125

101126
- name: Pack NetOffice
102-
if: steps.build.outputs.publish_nuget == 'true'
103127
run: |
104128
dotnet pack --no-build --no-restore Source\NetOffice.sln -c ${{ matrix.configuration }} -o dist
105129
env:
106130
VersionSuffix: ${{ steps.build.outputs.app_version_suffix }}
107131

108-
# - name: Sign NetOffice packages
109-
# if: success() && steps.build.outputs.publish_nuget == 'true' && steps.build.outputs.sign_binaries == 'true'
110-
# working-directory: '${{ github.workspace}}\dist'
111-
# run: |
112-
# NuGetKeyVaultSignTool.exe sign *.nupkg `
113-
# --file-digest sha256 `
114-
# --timestamp-rfc3161 http://timestamp.digicert.com `
115-
# --timestamp-digest sha256 `
116-
# --azure-key-vault-url https://opensourcesigning.vault.azure.net `
117-
# --azure-key-vault-tenant-id "${{ secrets.KEYVAULT_TENANT_ID }}" `
118-
# --azure-key-vault-client-id "${{ secrets.KEYVAULT_CLIENT_ID }}" `
119-
# --azure-key-vault-client-secret "${{ secrets.KEYVAULT_CLIENT_SECRET }}" `
120-
# --azure-key-vault-certificate "goITSolutions-until-2024-01"
121-
122-
- name: Publish packages
123-
if: success() && steps.build.outputs.publish_nuget == 'true'
132+
- name: Sign NetOffice packages
133+
if: success() && steps.build.outputs.sign_binaries == 'true'
124134
working-directory: '${{ github.workspace}}\dist'
125135
run: |
126-
dotnet nuget push *.nupkg --api-key $env:NUGET_TOKEN --source https://api.nuget.org/v3/index.json
127-
env:
128-
NUGET_TOKEN: ${{ secrets.NUGET_TOKEN }}
136+
sign code trusted-signing *.nupkg `
137+
--publisher-name "NetOffice" `
138+
--description "NetOffice" `
139+
--description-url "https://github.com/NetOfficeFw/NetOffice" `
140+
--trusted-signing-endpoint "${{ secrets.TRUSTED_SIGNING_ENDPOINT }}" `
141+
--trusted-signing-account "${{ secrets.TRUSTED_SIGNING_ACCOUNT_NAME }}" `
142+
--trusted-signing-certificate-profile "${{ secrets.TRUSTED_SIGNING_CERTIFICATE_PROFILE }}" `
143+
--file-digest SHA256 `
144+
--timestamp-url http://timestamp.acs.microsoft.com `
145+
--timestamp-digest SHA256
146+
147+
- name: Extract trusted signing certificate
148+
if: success() && steps.build.outputs.sign_binaries == 'true'
149+
run: |
150+
$nupkg = Get-ChildItem -Path '${{ github.workspace}}\dist' -Filter '*.nupkg' | Select-Object -First 1
151+
nuget-cert-extractor --file $nupkg --output '${{ github.workspace}}\dist' --code-signing --author --leaf
129152
130153
- name: Archive NetOffice packages
131-
if: success() && steps.build.outputs.publish_nuget == 'true'
132-
uses: actions/upload-artifact@v3
154+
if: success()
155+
uses: actions/upload-artifact@v5
133156
with:
134-
name: NetOffice_packages_v${{ steps.build.outputs.app_version_full }}
157+
name: ${{ steps.build.outputs.nuget_packages_artifact_name }}
135158
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 }}

.github/workflows/tests.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,18 @@ jobs:
3131

3232
steps:
3333
- name: Checkout
34-
uses: actions/checkout@v3
34+
uses: actions/checkout@v5
3535

3636
- name: Setup dotnet
37-
uses: actions/setup-dotnet@v3
37+
uses: actions/setup-dotnet@v5
3838
with:
39-
dotnet-version: '7.0.201'
39+
dotnet-version: 8
4040

4141
- name: Setup MSBuild
42-
uses: microsoft/setup-msbuild@v1.1
42+
uses: microsoft/setup-msbuild@v2
4343

4444
- name: Cache packages
45-
uses: actions/cache@v3
45+
uses: actions/cache@v4
4646
with:
4747
path: ~/.nuget/packages
4848
key: NetOffice-nuget-${{ hashFiles('**/packages.lock.json') }}
@@ -66,7 +66,7 @@ jobs:
6666
VersionSuffix: ${{ steps.build.outputs.app_version_suffix }}
6767

6868
- name: Archive NetOffice binaries
69-
uses: actions/upload-artifact@v3
69+
uses: actions/upload-artifact@v5
7070
with:
7171
name: NetOffice_binaries_v${{ steps.build.outputs.app_version_full }}_${{ matrix.configuration }}
7272
path: '${{ github.workspace }}\Source\ClientApplication\bin\${{ matrix.configuration }}'

Source/ClientApplication/packages.lock.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,6 @@
167167
}
168168
}
169169
},
170-
".NETFramework,Version=v4.6.2/win7-x86": {}
170+
".NETFramework,Version=v4.6.2/win-x86": {}
171171
}
172172
}

0 commit comments

Comments
 (0)