Skip to content

Commit bb9d928

Browse files
committed
fix: Handle compressed/noncompressed GPG keys in robust way
1 parent 3748eda commit bb9d928

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

dist/index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,11 @@ const toolCache = __importStar(__nccwpck_require__(7784));
7979
async function setupKeys() {
8080
core.debug("Fetching verification keys");
8181
let path = await toolCache.downloadTool("https://swift.org/keys/all-keys.asc");
82+
core.debug("Examining verification keys");
83+
await (0, exec_1.exec)(`file "${path}"`);
84+
const isPlaintext = await (0, exec_1.exec)(`gunzip --test "${path}"`, undefined, { silent: true, ignoreReturnCode: true });
8285
core.debug("Importing verification keys");
83-
await (0, exec_1.exec)(`gpg --import "${path}"`);
86+
await (0, exec_1.exec)('bash', ['-c', `${isPlaintext ? "cat" : "zcat"} "${path}" | gpg --import`]);
8487
core.debug("Refreshing keys");
8588
await refreshKeys();
8689
}

src/gpg.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,12 @@ export async function setupKeys() {
88
"https://swift.org/keys/all-keys.asc"
99
);
1010

11+
core.debug("Examining verification keys");
12+
await exec(`file "${path}"`);
13+
const isPlaintext = await exec(`gunzip --test "${path}"`, undefined, { silent: true, ignoreReturnCode: true });
14+
1115
core.debug("Importing verification keys");
12-
await exec(`gpg --import "${path}"`);
16+
await exec('bash', ['-c', `${isPlaintext ? "cat" : "zcat"} "${path}" | gpg --import`]);
1317

1418
core.debug("Refreshing keys");
1519
await refreshKeys();

0 commit comments

Comments
 (0)