Skip to content

Commit ab1a633

Browse files
committed
use azuresigntool
1 parent 4086e4b commit ab1a633

File tree

2 files changed

+8
-58
lines changed

2 files changed

+8
-58
lines changed

.github/workflows/release.yml

Lines changed: 7 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -73,72 +73,22 @@ jobs:
7373
go.sum
7474
.goreleaser-windows.yaml
7575
76-
- name: Add signtool to PATH
76+
- name: Azure Login and get Key Vault token
7777
shell: pwsh
7878
run: |
79-
# Find signtool in Windows SDK
80-
$signtoolPath = Get-ChildItem -Path "C:\Program Files (x86)\Windows Kits\10\bin" -Recurse -Filter "signtool.exe" -ErrorAction SilentlyContinue |
81-
Where-Object { $_.FullName -match "x64" } |
82-
Select-Object -First 1 -ExpandProperty DirectoryName
83-
84-
if ($signtoolPath) {
85-
Write-Host "Found signtool at: $signtoolPath"
86-
echo "$signtoolPath" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
87-
} else {
88-
Write-Error "signtool not found"
89-
exit 1
90-
}
91-
92-
- name: Install Azure Code Signing tools
93-
shell: pwsh
94-
run: |
95-
# Download and install Azure Code Signing tools
96-
Invoke-WebRequest -Uri "https://www.nuget.org/api/v2/package/Microsoft.Trusted.Signing.Client" -OutFile "$env:TEMP\TrustedSigning.zip"
97-
Expand-Archive -Path "$env:TEMP\TrustedSigning.zip" -DestinationPath "$env:TEMP\TrustedSigning" -Force
98-
99-
# Add to PATH so signtool can find the dlib
100-
$dllPath = (Get-ChildItem -Path "$env:TEMP\TrustedSigning" -Recurse -Filter "Azure.CodeSigning.Dlib.dll" | Select-Object -First 1).DirectoryName
101-
echo "$dllPath" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
102-
103-
- name: Azure Login
104-
shell: pwsh
105-
run: |
106-
# Login to public Azure (not Germany) for Code Signing service
10779
az login --service-principal `
10880
-u ${{ secrets.DECO_SIGN_AZURE_CLIENT_ID }} `
10981
-p ${{ secrets.DECO_SIGN_AZURE_CLIENT_SECRET }} `
11082
--tenant ${{ secrets.DECO_SIGN_AZURE_TENANT_ID }}
11183
112-
- name: Create Azure Code Signing metadata
113-
shell: pwsh
114-
run: |
115-
$metadata = @{
116-
"Endpoint" = "https://eus.codesigning.azure.net/"
117-
"CodeSigningAccountName" = "deco-sign"
118-
"CertificateProfileName" = "deco-sign"
119-
}
120-
$metadata | ConvertTo-Json | Out-File -FilePath "metadata.json" -Encoding utf8
121-
122-
- name: Create signing script
84+
$accessToken = az account get-access-token --resource https://vault.azure.net --query accessToken -o tsv
85+
echo "::add-mask::$accessToken"
86+
echo "AZURE_VAULT_TOKEN=$accessToken" >> $env:GITHUB_ENV
87+
88+
- name: Install AzureSignTool
12389
shell: pwsh
12490
run: |
125-
$script = @'
126-
$env:AZURE_TENANT_ID = "${{ secrets.DECO_SIGN_AZURE_TENANT_ID }}"
127-
$env:AZURE_CLIENT_ID = "${{ secrets.DECO_SIGN_AZURE_CLIENT_ID }}"
128-
$env:AZURE_CLIENT_SECRET = "${{ secrets.DECO_SIGN_AZURE_CLIENT_SECRET }}"
129-
130-
$filePath = $args[0]
131-
Write-Host "Signing: $filePath"
132-
133-
& signtool sign /fd SHA256 /tr http://timestamp.digicert.com /td SHA256 /dlib Azure.CodeSigning.Dlib.dll /dmdf metadata.json "$filePath"
134-
135-
if ($LASTEXITCODE -ne 0) {
136-
Write-Error "Signing failed with exit code $LASTEXITCODE"
137-
exit $LASTEXITCODE
138-
}
139-
'@
140-
141-
$script | Out-File -FilePath "sign.ps1" -Encoding utf8
91+
dotnet tool install --global AzureSignTool
14292
14393
- name: Run GoReleaser for Windows
14494
uses: goreleaser/goreleaser-action@e435ccd777264be153ace6237001ef4d979d3a7a # v6.4.0

.goreleaser-windows.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ builds:
4141

4242
hooks:
4343
post:
44-
- pwsh -File sign.ps1 "{{ .Path }}"
44+
- azuresigntool sign --azure-key-vault-url "https://deco-sign.vault.microsoftazure.de/" --azure-key-vault-client-id "{{ .Env.AZURE_CLIENT_ID }}" --azure-key-vault-client-secret "{{ .Env.AZURE_CLIENT_SECRET }}" --azure-key-vault-tenant-id "{{ .Env.AZURE_TENANT_ID }}" --azure-key-vault-certificate "deco-sign" --file-digest sha256 --timestamp-rfc3161 http://timestamp.digicert.com --timestamp-digest sha256 "{{ .Path }}"
4545

4646
archives:
4747
- formats: ["zip"]

0 commit comments

Comments
 (0)