Skip to content

Commit

Permalink
Merge pull request #7 from dargmuesli/timestamp
Browse files Browse the repository at this point in the history
Add last tag's timestamp
  • Loading branch information
WyriHaximus authored Oct 5, 2020
2 parents 8ea0fe9 + ac4f130 commit 24cf9bd
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,33 @@ 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;
}

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: ');
console.log('\x1b[31m%s\x1b[0m', stderr);
process.exit(1);

return;
}

tag = tag.trim()

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(`::set-output name=tag::${tag}`);
process.exit(0);
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);
});
});
});

0 comments on commit 24cf9bd

Please sign in to comment.