From 8804d3fb9aa8a3d689fbfe484ce65ea43f3a64ec Mon Sep 17 00:00:00 2001 From: Jonas Thelemann Date: Mon, 5 Oct 2020 03:17:47 +0200 Subject: [PATCH 1/3] chore: remove redundant returns --- main.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/main.js b/main.js index 90fdbc0..5cb71e4 100644 --- a/main.js +++ b/main.js @@ -4,8 +4,6 @@ exec('git rev-list --tags --max-count=1', (err, rev, stderr) => { console.log('\x1b[33m%s\x1b[0m', 'Could not find any revisions because: '); console.log('\x1b[31m%s\x1b[0m', stderr); process.exit(1); - - return; } exec(`git describe --tags ${rev}`, (err, tag, stderr) => { @@ -13,8 +11,6 @@ exec('git rev-list --tags --max-count=1', (err, rev, stderr) => { console.log('\x1b[33m%s\x1b[0m', 'Could not find any tags because: '); console.log('\x1b[31m%s\x1b[0m', stderr); process.exit(1); - - return; } From bcffe8d8eeae7dc3b86b9b5770ae3bf03be4bcdb Mon Sep 17 00:00:00 2001 From: Jonas Thelemann Date: Mon, 5 Oct 2020 03:18:26 +0200 Subject: [PATCH 2/3] fix: trim values --- main.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/main.js b/main.js index 5cb71e4..fc139dc 100644 --- a/main.js +++ b/main.js @@ -6,6 +6,8 @@ exec('git rev-list --tags --max-count=1', (err, rev, stderr) => { process.exit(1); } + rev = rev.trim() + exec(`git describe --tags ${rev}`, (err, tag, stderr) => { if (err) { console.log('\x1b[33m%s\x1b[0m', 'Could not find any tags because: '); @@ -13,6 +15,7 @@ exec('git rev-list --tags --max-count=1', (err, rev, stderr) => { process.exit(1); } + tag = tag.trim() console.log('\x1b[32m%s\x1b[0m', `Found tag: ${tag}`); console.log(`::set-output name=tag::${tag}`); From ac4f13077e82dcd632cc98b9a6f103265d664f49 Mon Sep 17 00:00:00 2001 From: Jonas Thelemann Date: Mon, 5 Oct 2020 03:20:05 +0200 Subject: [PATCH 3/3] feat: add timestamp --- main.js | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/main.js b/main.js index fc139dc..2dc252d 100644 --- a/main.js +++ b/main.js @@ -17,8 +17,20 @@ exec('git rev-list --tags --max-count=1', (err, rev, stderr) => { tag = tag.trim() - console.log('\x1b[32m%s\x1b[0m', `Found tag: ${tag}`); - console.log(`::set-output name=tag::${tag}`); - process.exit(0); + exec(`git log -1 --format=%at ${tag}`, (err, timestamp, stderr) => { + if (err) { + console.log('\x1b[33m%s\x1b[0m', 'Could not find any timestamp because: '); + console.log('\x1b[31m%s\x1b[0m', stderr); + process.exit(1); + } + + timestamp = timestamp.trim() + + console.log('\x1b[32m%s\x1b[0m', `Found tag: ${tag}`); + console.log('\x1b[32m%s\x1b[0m', `Found timestamp: ${timestamp}`); + console.log(`::set-output name=tag::${tag}`); + console.log(`::set-output name=timestamp::${timestamp}`); + process.exit(0); + }); }); });