Skip to content

Commit 4167d88

Browse files
committed
publish: set username+email
1 parent 8ceb3ca commit 4167d88

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/publish.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,14 @@ export async function publish(args) {
234234
writeFileSync(packageJsonPath, _originalPackageJson, 'utf-8');
235235

236236
if (args.createGitTag) {
237-
const cmd = `git tag -a ${packageJson.version} -m "Published ${packageJson.version}"`;
237+
238+
let cmd = `git tag -a ${packageJson.version} -m "Published ${packageJson.version}"`;
239+
240+
// set username and email for git
241+
const gitUserName = process.env.GIT_USER_NAME || 'Needle Npm Publish';
242+
const gitUserEmail = process.env.GIT_USER_EMAIL || 'hi+git@needle.tools';
243+
cmd = `git config user.name "${gitUserName}" && git config user.email "${gitUserEmail}" && ${cmd}`;
244+
238245
logger.info(`Creating git tag with command: ${cmd}`);
239246
const res = tryExecSync(cmd, {
240247
cwd: packageDirectory,
@@ -243,7 +250,7 @@ export async function publish(args) {
243250
if (!res.success) {
244251
logger.error(`❌ Failed to create git tag: ${res.error}`);
245252
if (webhook) {
246-
await sendMessageToWebhook(webhook, `❌ **Failed to create git tag** \`${packageJson.version}\`: ${res.error}`);
253+
await sendMessageToWebhook(webhook, `❌ **Failed to create git tag** \`${packageJson.version}\`:\n\`\`\`\n${res.error}\n\`\`\``);
247254
}
248255
}
249256
}

0 commit comments

Comments
 (0)