Skip to content

Commit 4bd6820

Browse files
authored
feat(git-node): verify tag signature during release promotion (#879)
1 parent e90258c commit 4bd6820

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

lib/promote_release.js

+23
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ export default class ReleasePromotion extends Session {
131131
throw new Error('Aborted');
132132
}
133133
await this.secureTagRelease();
134+
await this.verifyTagSignature();
134135

135136
// Set up for next release.
136137
cli.startSpinner('Setting up for next release');
@@ -223,6 +224,28 @@ export default class ReleasePromotion extends Session {
223224
this.isLTS ? '=false' : ''} --title=${JSON.stringify(this.releaseTitle)} --notes-file -`);
224225
}
225226

227+
async verifyTagSignature() {
228+
const { cli, version } = this;
229+
const [needle, haystack] = await Promise.all([forceRunAsync(
230+
'git', ['--no-pager',
231+
'log', '-1',
232+
`refs/tags/v${version}`,
233+
'--format=* **%an** <<%ae>>\n `%GF`'
234+
], { captureStdout: true }), fs.readFile('README.md')]);
235+
if (haystack.includes(needle)) {
236+
return;
237+
}
238+
cli.warn('Tag was signed with an undocumented identity/key pair!');
239+
cli.info('Expected to find the following entry in the README:');
240+
cli.info(needle);
241+
cli.info('If you are using a subkey, it might be OK.');
242+
cli.info(`Otherwise consider removing the tag (git tag -d v${version
243+
}), check your local config, and start the process over.`);
244+
if (!await cli.prompt('Do you want to proceed anyway?', { defaultAnswer: false })) {
245+
throw new Error('Aborted');
246+
}
247+
}
248+
226249
async verifyPRAttributes() {
227250
const { cli, prid, owner, repo, req } = this;
228251

0 commit comments

Comments
 (0)