Skip to content

Commit

Permalink
Invoke signing function for Windows Connect binary (#41963) (#42472)
Browse files Browse the repository at this point in the history
Co-authored-by: Grzegorz Zdunek <gzdunek@users.noreply.github.com>
  • Loading branch information
fheinecke and gzdunek authored Jun 5, 2024
1 parent d3ac572 commit be2fefa
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
11 changes: 10 additions & 1 deletion build.assets/windows/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function New-TempDirectory {
string
#>

$TempDirectoryPath = Join-Path -Path "$([System.IO.Path]::GetTempPath())" -ChildPath "$($(New-Guid).Guid)"
$TempDirectoryPath = Join-Path -Path "$([System.IO.Path]::GetTempPath())" -ChildPath "$([guid]::newguid().Guid)"
New-Item -ItemType Directory -Path "$TempDirectoryPath" | Out-Null

return "$TempDirectoryPath"
Expand Down Expand Up @@ -298,8 +298,17 @@ function Invoke-SignBinary {
[string] $SignedBinaryPath
)

if (! $SignedBinaryPath) {
$ShouldMoveSignedBinary = $true
$SignedBinaryPath = Join-Path -Path $(New-TempDirectory) -ChildPath "signed.exe"
}

Write-Host "Signing $UnsignedBinaryPath using WSL sign-binary script:"
wsl-ubuntu-command sign-binary "$UnsignedBinaryPath" "$SignedBinaryPath"

if ($ShouldMoveSignedBinary) {
Move-Item -Path $SignedBinaryPath -Destination $UnsignedBinaryPath -Force
}
}

function Build-WindowsAuthenticationPackage {
Expand Down
26 changes: 25 additions & 1 deletion web/packages/teleterm/electron-builder-config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { env, platform } = require('process');
const fs = require('fs');

const { spawnSync } = require('child_process');
const isMac = platform === 'darwin';

// The following checks make no sense when cross-building because they check the platform of the
Expand Down Expand Up @@ -142,6 +142,30 @@ module.exports = {
},
win: {
target: ['nsis'],
// The algorithm passed here is not used, it only prevents the signing function from being called twice for each file.
// https://github.com/electron-userland/electron-builder/issues/3995#issuecomment-505725704
signingHashAlgorithms: ['sha256'],
sign: customSign => {
if (process.env.CI !== 'true') {
console.warn('Not running in CI pipeline: signing will be skipped');
return;
}

spawnSync(
'powershell',
[
'-noprofile',
'-executionpolicy',
'bypass',
'-c',
"$ProgressPreference = 'SilentlyContinue'; " +
"$ErrorActionPreference = 'Stop'; " +
'. ../../../build.assets/windows/build.ps1; ' +
`Invoke-SignBinary -UnsignedBinaryPath "${customSign.path}"`,
],
{ stdio: 'inherit' }
);
},
artifactName: '${productName} Setup-${version}.${ext}',
icon: 'build_resources/icon-win.ico',
extraResources: [
Expand Down

0 comments on commit be2fefa

Please sign in to comment.