Skip to content

Commit d9471c4

Browse files
committed
fix: Handle compressed/noncompressed keys reliably
1 parent 0ff4bad commit d9471c4

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

dist/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,9 @@ async function setupKeys() {
8181
let path = await toolCache.downloadTool("https://swift.org/keys/all-keys.asc");
8282
core.debug("Examining verification keys");
8383
await (0, exec_1.exec)(`file "${path}"`);
84+
const isPlaintext = await (0, exec_1.exec)(`gunzip --test "${path}"`, undefined, { silent: true });
8485
core.debug("Importing verification keys");
85-
await (0, exec_1.exec)('bash', ['-c', `zcat "${path}" | gpg --import`]);
86+
await (0, exec_1.exec)('bash', ['-c', `${isPlaintext ? "cat" : "zcat"} "${path}" | gpg --import`]);
8687
core.debug("Refreshing keys");
8788
await refreshKeys();
8889
}

src/gpg.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ export async function setupKeys() {
1010

1111
core.debug("Examining verification keys");
1212
await exec(`file "${path}"`);
13+
const isPlaintext = await exec(`gunzip --test "${path}"`, undefined, { silent: true });
1314

1415
core.debug("Importing verification keys");
15-
await exec('bash', ['-c', `zcat "${path}" | gpg --import`]);
16+
await exec('bash', ['-c', `${isPlaintext ? "cat" : "zcat"} "${path}" | gpg --import`]);
1617

1718
core.debug("Refreshing keys");
1819
await refreshKeys();

0 commit comments

Comments
 (0)