Skip to content

Commit 062c051

Browse files
committed
Fix gpg handling on windows
1 parent 54b6830 commit 062c051

File tree

3 files changed

+22
-14
lines changed

3 files changed

+22
-14
lines changed

src/gpg.ts

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,33 @@
11
import { exec } from "@actions/exec";
22
import * as core from "@actions/core";
33
import * as toolCache from "@actions/tool-cache";
4+
import { OS, System } from "./os";
45

5-
export async function setupKeys() {
6+
export async function setupKeys(system: System) {
67
core.debug("Fetching verification keys");
78
let path = await toolCache.downloadTool(
89
"https://swift.org/keys/all-keys.asc"
910
);
1011

11-
core.debug("Examining verification keys");
12-
await exec(`file "${path}"`);
13-
const isPlaintext = await exec(`gunzip --test "${path}"`, undefined, {
14-
silent: true,
15-
ignoreReturnCode: true,
16-
});
12+
if (system.os === OS.Ubuntu || system.os === OS.MacOS) {
13+
core.debug("Examining verification keys");
14+
await exec(`file "${path}"`);
15+
const isPlaintext = await exec(`gunzip --test "${path}"`, undefined, {
16+
silent: true,
17+
ignoreReturnCode: true,
18+
});
19+
20+
core.debug("Importing verification keys");
21+
await exec("bash", [
22+
"-c",
23+
`${isPlaintext ? "cat" : "zcat"} "${path}" | gpg --import`,
24+
]);
25+
}
1726

18-
core.debug("Importing verification keys");
19-
await exec("bash", [
20-
"-c",
21-
`${isPlaintext ? "cat" : "zcat"} "${path}" | gpg --import`,
22-
]);
27+
if (system.os === OS.Windows) {
28+
core.debug("Importing verification keys");
29+
await exec(`gpg --import "${path}"`);
30+
}
2331

2432
core.debug("Refreshing keys");
2533
await refreshKeys();

src/linux-install.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export async function install(version: string, system: System) {
1818
if (swiftPath === null || swiftPath.trim().length == 0) {
1919
core.debug(`No matching installation found`);
2020

21-
await setupKeys();
21+
await setupKeys(system);
2222

2323
const swiftPkg = swiftPackage(version, system);
2424
let { pkg, signature } = await download(swiftPkg);

src/windows-install.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export async function install(version: string, system: System) {
2121
if (swiftPath === null || swiftPath.trim().length == 0) {
2222
core.debug(`No cached installer found`);
2323

24-
await setupKeys();
24+
await setupKeys(system);
2525

2626
let { exe, signature } = await download(swiftPkg);
2727
await verify(signature, exe);

0 commit comments

Comments
 (0)