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

fix(windows,code-sign): cannot sign binary files in Github Actions #8384

Merged
merged 1 commit into from
Jul 31, 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
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"
})
}
BlackHole1 marked this conversation as resolved.
Show resolved Hide resolved
Loading