Skip to content

Commit

Permalink
fix(windows,code-sign): cannot sign binary files in Github Actions (#…
Browse files Browse the repository at this point in the history
…8384)

Fixed: #7729 #8055

Signed-off-by: Kevin Cui <bh@bugs.cc>
  • Loading branch information
BlackHole1 authored Jul 31, 2024
1 parent 553c737 commit f8fbdd1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/good-news-stare.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"app-builder-lib": patch
---

Fix the issue of being unable to sign binary files in the Windows runner on Github Actions
19 changes: 16 additions & 3 deletions packages/app-builder-lib/src/codeSign/windowsCodeSign.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,9 @@ export interface CertificateFromStoreInfo {
export async function getCertificateFromStoreInfo(options: WindowsConfiguration, vm: VmManager): Promise<CertificateFromStoreInfo> {
const certificateSubjectName = options.certificateSubjectName
const certificateSha1 = options.certificateSha1 ? options.certificateSha1.toUpperCase() : options.certificateSha1
// ExcludeProperty doesn't work, so, we cannot exclude RawData, it is ok
// powershell can return object if the only item
const rawResult = await vm.exec("powershell.exe", [

const ps = await getPSCmd(vm)
const rawResult = await vm.exec(ps, [
"-NoProfile",
"-NonInteractive",
"-Command",
Expand Down Expand Up @@ -319,3 +319,16 @@ async function getToolPath(isWin = process.platform === "win32"): Promise<ToolIn
return { path: path.join(vendorPath, process.platform, "osslsigncode") }
}
}

async function getPSCmd(vm: VmManager): Promise<string> {
return await vm
.exec("powershell.exe", ["-NoProfile", "-NonInteractive", "-Command", `Get-Command pwsh.exe`])
.then(() => {
log.debug(null, "identified pwsh.exe for executing code signing")
return "pwsh.exe"
})
.catch(() => {
log.debug(null, "unable to find pwsh.exe, falling back to powershell.exe")
return "powershell.exe"
})
}

0 comments on commit f8fbdd1

Please sign in to comment.