From e4e25f0bab8e458580a7bdaad885e7d6fcd697d6 Mon Sep 17 00:00:00 2001 From: Dan Freeman Date: Mon, 13 Jul 2020 17:48:38 +0200 Subject: [PATCH] v2.0.1 --- dist/index.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/dist/index.js b/dist/index.js index f78a3b71..2c6f3abc 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1783,12 +1783,37 @@ exports.checkout = checkout; async function createTag(name, annotation) { let tagArgs = ['tag', name]; if (annotation.length) { + // If we're pushing an annotation, `user.name` and `user.email` must be configured. + await ensureUserIsConfigured(); tagArgs.push('-m', annotation); } await execa_1.default('git', tagArgs); await execa_1.default('git', ['push', '--tags']); } exports.createTag = createTag; +async function ensureUserIsConfigured() { + if (!(await hasConfig('user.name'))) { + await setConfig('user.name', 'github-actions'); + } + if (!(await hasConfig('user.email'))) { + await setConfig('user.email', 'github-actions@user.noreply.github.com'); + } +} +exports.ensureUserIsConfigured = ensureUserIsConfigured; +async function hasConfig(name) { + try { + await execa_1.default('git', ['config', name]); + return true; + } + catch (_a) { + return false; + } +} +exports.hasConfig = hasConfig; +async function setConfig(name, value) { + await execa_1.default('git', ['config', name, value]); +} +exports.setConfig = setConfig; /***/ }),