Skip to content

Commit 9f416c4

Browse files
committed
Sign Windows binaries with self-signed code signing certificate
Adds signtool signing for the native Windows .exe and osslsigncode signing for the cross-compiled NSIS installer. Certificate stored as GitHub secret (CODE_SIGNING_PFX). Signing is optional — builds still work without the secret.
1 parent c682a23 commit 9f416c4

1 file changed

Lines changed: 34 additions & 0 deletions

File tree

.github/workflows/release.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,20 @@ jobs:
8686
echo "name=${name}" >> "$GITHUB_OUTPUT"
8787
echo "version=${version}" >> "$GITHUB_OUTPUT"
8888
89+
- name: Sign Windows binary
90+
if: matrix.client == 'windows' && env.CODE_SIGNING_PFX != ''
91+
env:
92+
CODE_SIGNING_PFX: ${{ secrets.CODE_SIGNING_PFX }}
93+
CODE_SIGNING_PASSWORD: ${{ secrets.CODE_SIGNING_PASSWORD }}
94+
shell: pwsh
95+
run: |
96+
$pfxBytes = [Convert]::FromBase64String($env:CODE_SIGNING_PFX)
97+
[IO.File]::WriteAllBytes("$pwd\codesign.pfx", $pfxBytes)
98+
$exe = "${{ matrix.client }}\target\${{ matrix.target }}\release\screenmcp-${{ matrix.client }}.exe"
99+
$signtool = Get-ChildItem -Path "C:\Program Files (x86)\Windows Kits" -Recurse -Filter signtool.exe | Where-Object { $_.FullName -like "*x64*" } | Select-Object -First 1 -ExpandProperty FullName
100+
& $signtool sign /f codesign.pfx /p $env:CODE_SIGNING_PASSWORD /tr http://timestamp.digicert.com /td SHA256 /fd SHA256 $exe
101+
Remove-Item codesign.pfx
102+
89103
- name: Package macOS (.app + .dmg)
90104
if: matrix.client == 'mac'
91105
shell: bash
@@ -236,6 +250,26 @@ jobs:
236250
working-directory: windows
237251
run: ./build-installer.sh "${GITHUB_REF_NAME#v}"
238252

253+
- name: Sign Windows installer
254+
if: env.CODE_SIGNING_PFX != ''
255+
env:
256+
CODE_SIGNING_PFX: ${{ secrets.CODE_SIGNING_PFX }}
257+
CODE_SIGNING_PASSWORD: ${{ secrets.CODE_SIGNING_PASSWORD }}
258+
run: |
259+
sudo apt-get install -y osslsigncode
260+
echo "$CODE_SIGNING_PFX" | base64 -d > codesign.pfx
261+
version="${GITHUB_REF_NAME#v}"
262+
file="windows/target/installer/screenmcp-setup-${version}-x86_64.exe"
263+
osslsigncode sign \
264+
-pkcs12 codesign.pfx \
265+
-pass "$CODE_SIGNING_PASSWORD" \
266+
-ts http://timestamp.digicert.com \
267+
-h sha256 \
268+
-in "$file" \
269+
-out "${file}.signed"
270+
mv "${file}.signed" "$file"
271+
rm codesign.pfx
272+
239273
- name: Determine installer name
240274
id: installer
241275
shell: bash

0 commit comments

Comments
 (0)