Skip to content

Commit

Permalink
OpenPGP.js 5.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
crazy-max committed Sep 4, 2021
1 parent c68617e commit 3e473e8
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 38 deletions.
35 changes: 17 additions & 18 deletions dist/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -25,7 +25,7 @@
"@actions/core": "^1.4.0",
"@actions/exec": "^1.1.0",
"addressparser": "^1.0.1",
"openpgp": "^5.0.0-5"
"openpgp": "^5.0.0"
},
"devDependencies": {
"@types/jest": "^26.0.14",
Expand Down
29 changes: 14 additions & 15 deletions src/main.ts
Expand Up @@ -17,7 +17,7 @@ async function run(): Promise<void> {

const version = await gpg.getVersion();
const dirs = await gpg.getDirs();
await core.group(`📣 GnuPG info`, async () => {
await core.group(`GnuPG info`, async () => {
core.info(`Version : ${version.gnupg} (libgcrypt ${version.libgcrypt})`);
core.info(`Libdir : ${dirs.libdir}`);
core.info(`Libexecdir : ${dirs.libexecdir}`);
Expand All @@ -26,43 +26,42 @@ async function run(): Promise<void> {
});

const privateKey = await openpgp.readPrivateKey(inputs.gpgPrivateKey);
await core.group(`🔮 Checking GPG private key`, async () => {
await core.group(`GPG private key info`, async () => {
core.info(`Fingerprint : ${privateKey.fingerprint}`);
core.info(`KeyID : ${privateKey.keyID}`);
core.info(`Name : ${privateKey.name}`);
core.info(`Email : ${privateKey.email}`);
core.info(`CreationTime : ${privateKey.creationTime}`);
});

await core.group(`🔑 Importing GPG private key`, async () => {
await core.group(`Importing GPG private key`, async () => {
await gpg.importKey(inputs.gpgPrivateKey).then(stdout => {
core.info(stdout);
});
});

if (inputs.passphrase) {
core.info('⚙️ Configuring GnuPG agent');
core.info('Configuring GnuPG agent');
await gpg.configureAgent(gpg.agentConfig);

core.info('📌 Getting keygrips');
await core.group(`📌 Getting keygrips`, async () => {
await core.group(`Getting keygrips`, async () => {
for (let keygrip of await gpg.getKeygrips(privateKey.fingerprint)) {
core.info(`🔓 Presetting passphrase for ${keygrip}`);
core.info(`Presetting passphrase for ${keygrip}`);
await gpg.presetPassphrase(keygrip, inputs.passphrase).then(stdout => {
core.debug(stdout);
});
}
});
}

core.info('🛒 Setting outputs...');
core.info('Setting outputs');
context.setOutput('fingerprint', privateKey.fingerprint);
context.setOutput('keyid', privateKey.keyID);
context.setOutput('name', privateKey.name);
context.setOutput('email', privateKey.email);

if (inputs.gitUserSigningkey) {
core.info('🔐 Setting GPG signing keyID for this Git repository');
core.info('Setting GPG signing keyID for this Git repository');
await git.setConfig('user.signingkey', privateKey.keyID, inputs.gitConfigGlobal);

const userEmail = inputs.gitCommitterEmail || privateKey.email;
Expand All @@ -73,20 +72,20 @@ async function run(): Promise<void> {
return;
}

core.info(`🔨 Configuring Git committer (${userName} <${userEmail}>)`);
core.info(`Configuring Git committer (${userName} <${userEmail}>)`);
await git.setConfig('user.name', userName, inputs.gitConfigGlobal);
await git.setConfig('user.email', userEmail, inputs.gitConfigGlobal);

if (inputs.gitCommitGpgsign) {
core.info('💎 Sign all commits automatically');
core.info('Sign all commits automatically');
await git.setConfig('commit.gpgsign', 'true', inputs.gitConfigGlobal);
}
if (inputs.gitTagGpgsign) {
core.info('💎 Sign all tags automatically');
core.info('Sign all tags automatically');
await git.setConfig('tag.gpgsign', 'true', inputs.gitConfigGlobal);
}
if (inputs.gitPushGpgsign) {
core.info('💎 Sign all pushes automatically');
core.info('Sign all pushes automatically');
await git.setConfig('push.gpgsign', inputs.gitPushGpgsign, inputs.gitConfigGlobal);
}
}
Expand All @@ -101,11 +100,11 @@ async function cleanup(): Promise<void> {
return;
}
try {
core.info('🚿 Removing keys');
core.info('Removing keys');
const privateKey = await openpgp.readPrivateKey(stateHelper.gpgPrivateKey);
await gpg.deleteKey(privateKey.fingerprint);

core.info('💀 Killing GnuPG agent');
core.info('Killing GnuPG agent');
await gpg.killAgent();
} catch (error) {
core.warning(error.message);
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Expand Up @@ -2765,10 +2765,10 @@ onetime@^5.1.0:
dependencies:
mimic-fn "^2.1.0"

openpgp@^5.0.0-5:
version "5.0.0-5"
resolved "https://registry.yarnpkg.com/openpgp/-/openpgp-5.0.0-5.tgz#55b0b8e6825b0a651244ddd468f70af1a2922767"
integrity sha512-9UgpUiWzh14ciVWdCbWwXAeHJ7Vcnu1vnSs38kyYd9S+z1apP4A76jRpOrhG3Xl6yPG9p7jzspjU4y4LrDMjTQ==
openpgp@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/openpgp/-/openpgp-5.0.0.tgz#2da0ee406c8834223ae928a9a214f4811f83f923"
integrity sha512-H4Jsj9Bp1KFQ/w520M1d2x45iz9V39Lf+IwIXmUaBmJAMagAt0zanqmWeFzIMJUYmrHTcm6fO/rpc6aftFUHbA==
dependencies:
asn1.js "^5.0.0"

Expand Down

0 comments on commit 3e473e8

Please sign in to comment.