Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v15] Invoke signing function for Windows Connect binary #42472

Merged
merged 1 commit into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading