Skip to content

Commit f8fbdd1

Browse files
authoredJul 31, 2024··
fix(windows,code-sign): cannot sign binary files in Github Actions (#8384)
Fixed: #7729 #8055 Signed-off-by: Kevin Cui <bh@bugs.cc>
1 parent 553c737 commit f8fbdd1

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed
 

‎.changeset/good-news-stare.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"app-builder-lib": patch
3+
---
4+
5+
Fix the issue of being unable to sign binary files in the Windows runner on Github Actions

‎packages/app-builder-lib/src/codeSign/windowsCodeSign.ts

+16-3
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,9 @@ export interface CertificateFromStoreInfo {
110110
export async function getCertificateFromStoreInfo(options: WindowsConfiguration, vm: VmManager): Promise<CertificateFromStoreInfo> {
111111
const certificateSubjectName = options.certificateSubjectName
112112
const certificateSha1 = options.certificateSha1 ? options.certificateSha1.toUpperCase() : options.certificateSha1
113-
// ExcludeProperty doesn't work, so, we cannot exclude RawData, it is ok
114-
// powershell can return object if the only item
115-
const rawResult = await vm.exec("powershell.exe", [
113+
114+
const ps = await getPSCmd(vm)
115+
const rawResult = await vm.exec(ps, [
116116
"-NoProfile",
117117
"-NonInteractive",
118118
"-Command",
@@ -319,3 +319,16 @@ async function getToolPath(isWin = process.platform === "win32"): Promise<ToolIn
319319
return { path: path.join(vendorPath, process.platform, "osslsigncode") }
320320
}
321321
}
322+
323+
async function getPSCmd(vm: VmManager): Promise<string> {
324+
return await vm
325+
.exec("powershell.exe", ["-NoProfile", "-NonInteractive", "-Command", `Get-Command pwsh.exe`])
326+
.then(() => {
327+
log.debug(null, "identified pwsh.exe for executing code signing")
328+
return "pwsh.exe"
329+
})
330+
.catch(() => {
331+
log.debug(null, "unable to find pwsh.exe, falling back to powershell.exe")
332+
return "powershell.exe"
333+
})
334+
}

0 commit comments

Comments
 (0)
Please sign in to comment.