Skip to content

Commit

Permalink
Install gnupg automatically with brew in darwin (#17)
Browse files Browse the repository at this point in the history
Fixes #16
  • Loading branch information
mihails-strasuns authored Nov 25, 2019
1 parent 2e815af commit 66261c5
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 3 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ jobs:
if: (! startsWith(github.ref, 'v'))
run: npm install --production

- run: brew install gnupg
if: matrix.os == 'macOS-latest'

- name: Install D compiler
uses: ./
with:
Expand Down
10 changes: 10 additions & 0 deletions lib/gpg.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,13 @@ function verify(file_path, sig_url) {
});
}
exports.verify = verify;
function install() {
return __awaiter(this, void 0, void 0, function* () {
// other platforms have gpg pre-installed
if (process.platform == "darwin") {
const brew_process = promisify_child_process_1.spawn('brew', ['install', 'gnupg'], {});
yield brew_process;
}
});
}
exports.install = install;
1 change: 1 addition & 0 deletions lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ function run() {
const archive = yield tc.downloadTool(descr.url);
if (descr.sig) {
console.log("Verifying the download with GPG");
yield gpg.install();
yield gpg.verify(archive, descr.sig);
}
const dc_path = yield extract(descr.url, archive);
Expand Down
8 changes: 8 additions & 0 deletions src/gpg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,11 @@ export async function verify(file_path: string, sig_url: string) {
// will throw for non-0 exit status
await gpg_process;
}

export async function install() {
// other platforms have gpg pre-installed
if (process.platform == "darwin") {
const brew_process = <any> spawn('brew', [ 'install', 'gnupg' ], {});
await brew_process;
}
}
1 change: 1 addition & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ async function run() {
if (descr.sig)
{
console.log("Verifying the download with GPG");
await gpg.install();
await gpg.verify(archive, descr.sig);
}
const dc_path = await extract(descr.url, archive);
Expand Down

0 comments on commit 66261c5

Please sign in to comment.