Repository navigation
189 lines (156 loc) · 5.65 KB
/
Copy pathrelease.yml
File metadata and controls
189 lines (156 loc) · 5.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
name: release
on:
workflow_dispatch:
inputs:
dry_run:
description: Create a draft prerelease without publishing NuGet packages
required: false
default: true
type: boolean
push:
tags: [ 'v*.*.*' ]
permissions:
id-token: write
attestations: write
contents: write
env:
DOTNET_NOLOGO: 1
DOTNET_CLI_TELEMETRY_OPTOUT: 1
DOTNET_GENERATE_ASPNET_CERTIFICATE: 0
ContinuousIntegrationBuild: true
RestoreLockedMode: true
Configuration: Release
RepositoryBranch: '${{ github.ref_name }}'
RepositoryCommit: '${{ github.sha }}'
jobs:
release:
runs-on: ubuntu-24.04
environment:
name: production
url: https://www.nuget.org/packages/NetOfficeFw.VbaCompiler
steps:
- name: checkout
uses: actions/checkout@v7
- name: setup dotnet
uses: actions/setup-dotnet@v6
with:
dotnet-version: |
8
10
- name: restore
run: dotnet restore
- name: build
run: dotnet build --no-restore
- name: test
run: dotnet test --no-build --no-restore
- name: pack
run: |
dotnet pack src/VbaCompiler/VbaCompiler.csproj --no-build --no-restore -o dist
dotnet pack src/vbamc/vbamc.csproj --no-build --no-restore -o dist
- name: publish unsigned packages
uses: actions/upload-artifact@v7
with:
name: vbamc_unsigned_packages
path: |
${{ github.workspace }}/dist
${{ github.workspace }}/src/VbaCompiler/README.md
${{ github.workspace }}/src/vbamc/README.md
sign:
needs: release
runs-on: windows-2025
environment:
name: production
url: https://www.nuget.org/packages/NetOfficeFw.VbaCompiler
steps:
- name: checkout
uses: actions/checkout@v7
- name: download unsigned packages
uses: actions/download-artifact@v8
with:
name: vbamc_unsigned_packages
- name: setup dotnet
uses: actions/setup-dotnet@v6
with:
dotnet-version: 10
- name: setup dotnet sign tool
run: dotnet tool install --verbosity minimal --global sign --version 0.9.1-beta.26330.1
- name: setup Knapcode.CertificateExtractor tool
run: dotnet tool install --verbosity minimal --global Knapcode.CertificateExtractor --version 0.1.1
- name: azure login
uses: azure/login@v3
with:
client-id: ${{ secrets.ARTIFACTS_SIGNING_CLIENT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
- name: sign nuget packages
working-directory: '${{ github.workspace }}\\dist'
run: |
sign code artifact-signing *.nupkg `
--publisher-name "NetOfficeFw" `
--description "vbamc tool" `
--description-url "https://github.com/NetOfficeFw/vbamc" `
--artifact-signing-endpoint "${{ secrets.ARTIFACTS_SIGNING_ENDPOINT }}" `
--artifact-signing-account "${{ secrets.ARTIFACTS_SIGNING_ACCOUNT_NAME }}" `
--artifact-signing-certificate-profile "${{ secrets.ARTIFACTS_SIGNING_CERTIFICATE_PROFILE }}" `
--file-digest SHA256 `
--timestamp-url http://timestamp.acs.microsoft.com `
--timestamp-digest SHA256
- name: attestation
uses: actions/attest-build-provenance@v4
with:
subject-path: 'dist/*.nupkg'
show-summary: true
- name: extract code signing certificate
run: |
$nupkg = Get-ChildItem -Path '${{ github.workspace }}\dist' -Filter '*.nupkg' | Select-Object -First 1
nuget-cert-extractor --file $nupkg --output '${{ github.workspace }}\dist' --code-signing --author --leaf
- name: publish signed packages
uses: actions/upload-artifact@v7
with:
name: vbamc_packages
path: '${{ github.workspace }}\dist'
- name: publish code signing certificate
id: certificate_artifact
uses: actions/upload-artifact@v7
with:
name: certificate
path: '${{ github.workspace }}\dist\*.cer'
- name: signing certificate instructions
run: |
$certificateUrl = '${{ steps.certificate_artifact.outputs.artifact-url }}'
'Before approving the publish job, upload the code-signing certificate to NuGet Gallery via Account Settings: <https://www.nuget.org/account>.' >> $env:GITHUB_STEP_SUMMARY
"Download the [code-signing certificate]($certificateUrl)." >> $env:GITHUB_STEP_SUMMARY
- name: release
uses: softprops/action-gh-release@efb35369e0ad2afab669f228072c1b0d510eae64 # v3.0.3
if: ${{ !cancelled() && startsWith(github.ref, 'refs/tags/') }}
with:
name: 'vbamc ${{ github.ref_name }}'
body_path: ${{ github.workspace }}/RELEASE_NOTES.md
draft: ${{ github.event.inputs.dry_run == 'true' }}
prerelease: ${{ github.event.inputs.dry_run == 'true' }}
publish:
needs: sign
runs-on: ubuntu-24.04
environment:
name: nuget-gallery
url: https://www.nuget.org/packages/NetOfficeFw.VbaCompiler
permissions:
id-token: write
steps:
- name: download packages
uses: actions/download-artifact@v8
with:
name: vbamc_packages
path: ${{ github.workspace }}/dist
- name: authenticate nuget.org
uses: NetOfficeFw/nuget-login@v2
id: nuget
with:
user: ${{ secrets.NUGET_TRUSTED_PUBLISHING_USER }}
- name: publish
if: ${{ github.event.inputs.dry_run != 'true' }}
working-directory: '${{ github.workspace }}/dist'
run: |
dotnet nuget push "*.nupkg" --api-key "$NUGET_API_KEY" --source https://api.nuget.org/v3/index.json --skip-duplicate
env:
NUGET_API_KEY: ${{ steps.nuget.outputs.NUGET_API_KEY }}