Skip to content

Commit 4d3a8f1

Browse files
committed
release: update Windows to use Azure Code Signing
Update Windows component of release workflow to use Azure Code Signing.
1 parent 16e628a commit 4d3a8f1

File tree

1 file changed

+65
-75
lines changed

1 file changed

+65
-75
lines changed

.github/workflows/release.yml

Lines changed: 65 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -139,12 +139,13 @@ jobs:
139139
./payload/*
140140
141141
# ================================
142-
# Windows
142+
# Windows
143143
# ================================
144-
win-sign:
145-
name: Build and Sign Windows
144+
create-windows-artifacts:
145+
name: Create Windows Artifacts
146146
runs-on: windows-latest
147147
environment: release
148+
needs: prereqs
148149
steps:
149150
- uses: actions/checkout@v4
150151

@@ -153,9 +154,6 @@ jobs:
153154
with:
154155
dotnet-version: 7.0.x
155156

156-
- name: Install dependencies
157-
run: dotnet restore
158-
159157
- name: Build
160158
run: |
161159
dotnet build --configuration=WindowsRelease
@@ -165,80 +163,66 @@ jobs:
165163
dotnet test --configuration=WindowsRelease
166164
167165
- name: Lay out Windows payload and symbols
168-
shell: pwsh
169166
run: |
170-
cd src/windows/Installer.Windows/
171-
./layout.ps1 -Configuration WindowsRelease -Output payload -SymbolOutput symbols
172-
mkdir unsigned-payload
173-
Get-ChildItem -Path payload/* -Include *.exe, *.dll | Move-Item -Destination unsigned-payload
167+
cd $env:GITHUB_WORKSPACE\src\windows\Installer.Windows\
168+
./layout.ps1 -Configuration WindowsRelease `
169+
-Output $env:GITHUB_WORKSPACE\payload `
170+
-SymbolOutput $env:GITHUB_WORKSPACE\symbols
174171
175-
- uses: azure/login@v1
172+
- name: Log into Azure
173+
uses: azure/login@v1
176174
with:
177-
creds: ${{ secrets.AZURE_CREDENTIALS }}
178-
179-
- name: Set up ESRP client
180-
shell: pwsh
181-
env:
182-
AZURE_VAULT: ${{ secrets.AZURE_VAULT }}
183-
AUTH_CERT: ${{ secrets.AZURE_VAULT_AUTH_CERT_NAME }}
184-
REQUEST_SIGNING_CERT: ${{ secrets.AZURE_VAULT_REQUEST_SIGNING_CERT_NAME }}
185-
run: |
186-
.github\set_up_esrp.ps1
175+
client-id: ${{ secrets.AZURE_CLIENT_ID }}
176+
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
177+
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
187178

188-
- name: Run ESRP client for unsigned payload
189-
shell: pwsh
190-
env:
191-
AZURE_AAD_ID: ${{ secrets.AZURE_AAD_ID }}
192-
WINDOWS_KEY_CODE: ${{ secrets.WINDOWS_KEY_CODE }}
193-
WINDOWS_OP_CODE: ${{ secrets.WINDOWS_OPERATION_CODE }}
194-
run: |
195-
python .github\run_esrp_signing.py `
196-
src/windows/Installer.Windows/unsigned-payload `
197-
$env:WINDOWS_KEY_CODE $env:WINDOWS_OP_CODE `
198-
--params 'OpusName' 'Microsoft' `
199-
'OpusInfo' 'http://www.microsoft.com' `
200-
'FileDigest' '/fd "SHA256"' 'PageHash' '/NPH' `
201-
'TimeStamp' '/tr \"http://rfc3161.gtm.corp.microsoft.com/TSS/HttpTspServer\" /td sha256'
202-
203-
- name: Lay out signed payload
204-
shell: pwsh
205-
run: |
206-
mkdir signed-payload
207-
Move-Item -Path signed/* -Destination signed-payload
208-
# ESRP will not sign the *.exe.config or NOTICE files, but they are needed to build the installers.
209-
# Due to this, we copy them after signing.
210-
Get-ChildItem -Path src/windows/Installer.Windows/payload/* -Include *.exe.config, NOTICE | Move-Item -Destination signed-payload
211-
Remove-Item signed -Recurse -Force
179+
- name: Sign payload files with Azure Code Signing
180+
uses: azure/[email protected]
181+
with:
182+
endpoint: https://wus2.codesigning.azure.net/
183+
code-signing-account-name: git-fundamentals-signing
184+
certificate-profile-name: git-fundamentals-windows-signing
185+
files-folder: ${{ github.workspace }}\payload
186+
files-folder-filter: exe,dll
187+
file-digest: SHA256
188+
timestamp-rfc3161: http://timestamp.acs.microsoft.com
189+
timestamp-digest: SHA256
190+
191+
# The Azure Code Signing action overrides the .NET version, so we reset it.
192+
- name: Set up .NET
193+
uses: actions/[email protected]
194+
with:
195+
dotnet-version: 7.0.x
212196

213197
- name: Build with signed payload
214-
shell: pwsh
215198
run: |
216-
dotnet build src/windows/Installer.Windows /p:PayloadPath=$env:GITHUB_WORKSPACE/signed-payload /p:NoLayout=true --configuration=WindowsRelease
199+
dotnet build $env:GITHUB_WORKSPACE\src\windows\Installer.Windows `
200+
/p:PayloadPath=$env:GITHUB_WORKSPACE\payload /p:NoLayout=true `
201+
--configuration=WindowsRelease
202+
mkdir installers
203+
Move-Item -Path .\out\windows\Installer.Windows\bin\Release\net472\*.exe `
204+
-Destination $env:GITHUB_WORKSPACE\installers
205+
206+
- name: Sign installers with Azure Code Signing
207+
uses: azure/[email protected]
208+
with:
209+
endpoint: https://wus2.codesigning.azure.net/
210+
code-signing-account-name: git-fundamentals-signing
211+
certificate-profile-name: git-fundamentals-windows-signing
212+
files-folder: ${{ github.workspace }}\installers
213+
files-folder-filter: exe
214+
file-digest: SHA256
215+
timestamp-rfc3161: http://timestamp.acs.microsoft.com
216+
timestamp-digest: SHA256
217217

218-
- name: Run ESRP client for installers
219-
shell: pwsh
220-
env:
221-
AZURE_AAD_ID: ${{ secrets.AZURE_AAD_ID }}
222-
WINDOWS_KEY_CODE: ${{ secrets.WINDOWS_KEY_CODE }}
223-
WINDOWS_OP_CODE: ${{ secrets.WINDOWS_OPERATION_CODE }}
224-
run: |
225-
python .github\run_esrp_signing.py `
226-
.\out\windows\Installer.Windows\bin\WindowsRelease\net472 `
227-
$env:WINDOWS_KEY_CODE `
228-
$env:WINDOWS_OP_CODE `
229-
--params 'OpusName' 'Microsoft' `
230-
'OpusInfo' 'http://www.microsoft.com' `
231-
'FileDigest' '/fd "SHA256"' 'PageHash' '/NPH' `
232-
'TimeStamp' '/tr \"http://rfc3161.gtm.corp.microsoft.com/TSS/HttpTspServer\" /td sha256'
233-
234-
- name: Publish final artifacts
218+
- name: Upload artifacts
235219
uses: actions/upload-artifact@v3
236220
with:
237-
name: win-sign
221+
name: windows-artifacts
238222
path: |
239-
signed
240-
signed-payload
241-
src/windows/Installer.Windows/symbols
223+
payload
224+
installers
225+
symbols
242226
243227
# ================================
244228
# Linux
@@ -511,7 +495,7 @@ jobs:
511495
command: git-credential-manager
512496
description: osx-x64
513497
- os: windows-latest
514-
artifact: win-sign
498+
artifact: windows-artifacts
515499
# Even when a standalone GCM version is installed, GitHub actions
516500
# runners still only recognize the version bundled with Git for
517501
# Windows due to its placement on the PATH. For this reason, we use
@@ -523,10 +507,15 @@ jobs:
523507
command: git-credential-manager
524508
description: dotnet-tool
525509
runs-on: ${{ matrix.component.os }}
526-
needs: [ create-macos-artifacts, win-sign, create-linux-artifacts, dotnet-tool-sign ]
510+
needs: [ create-macos-artifacts, create-windows-artifacts, create-linux-artifacts, dotnet-tool-sign ]
527511
steps:
528512
- uses: actions/checkout@v4
529513

514+
- name: Set up .NET
515+
uses: actions/[email protected]
516+
with:
517+
dotnet-version: 7.0.x
518+
530519
- name: Download artifacts
531520
uses: actions/download-artifact@v3
532521
with:
@@ -536,7 +525,7 @@ jobs:
536525
if: contains(matrix.component.description, 'windows')
537526
shell: pwsh
538527
run: |
539-
$exePaths = Get-ChildItem -Path ./signed/*.exe | %{$_.FullName}
528+
$exePaths = Get-ChildItem -Path ./installers/*.exe | %{$_.FullName}
540529
foreach ($exePath in $exePaths)
541530
{
542531
Start-Process -Wait -FilePath "$exePath" -ArgumentList "/SILENT /VERYSILENT /NORESTART"
@@ -610,9 +599,10 @@ jobs:
610599
611600
- name: Archive Windows payload and symbols
612601
run: |
602+
version="${{ needs.prereqs.outputs.version }}"
613603
mkdir win-x86-payload-and-symbols
614-
zip -jr win-x86-payload-and-symbols/gcm-win-x86-$VERSION.zip win-sign/signed-payload
615-
zip -jr win-x86-payload-and-symbols/gcm-win-x86-$VERSION-symbols.zip win-sign/src/windows/Installer.Windows/symbols
604+
zip -jr win-x86-payload-and-symbols/gcm-win-x86-$version.zip windows-artifacts/payload
605+
zip -jr win-x86-payload-and-symbols/gcm-win-x86-$version-symbols.zip windows-artifacts/symbols
616606
617607
- uses: actions/github-script@v6
618608
with:
@@ -660,7 +650,7 @@ jobs:
660650
661651
await Promise.all([
662652
// Upload Windows artifacts
663-
uploadDirectoryToRelease('win-sign/signed'),
653+
uploadDirectoryToRelease('windows-artifacts/installers'),
664654
uploadDirectoryToRelease('win-x86-payload-and-symbols'),
665655
666656
// Upload macOS artifacts

0 commit comments

Comments
 (0)