Files
goreleaser-action/src/git.ts
T
CrazyMax e198786300 improvement: Review snapshot behavior (#95)
* Improve git tag detection (#77)
* Only handle snapshot flag for release cmd (#94)
* Use core.info instead of console.log
* Update gitattributes
2020-02-11 13:52:06 +01:00

26 lines
671 B
TypeScript

import * as child_process from 'child_process';
const git = async (args: string[] = []) => {
const stdout = child_process.execSync(`git ${args.join(' ')}`, {
encoding: 'utf8'
});
return stdout.trim();
};
export async function isTagDirty(currentTag: string): Promise<boolean> {
try {
await git(['describe', '--exact-match', '--tags', '--match', currentTag]);
} catch (err) {
return true;
}
return false;
}
export async function getTag(): Promise<string> {
return await git(['describe', '--tags', '--abbrev=0']);
}
export async function getShortCommit(): Promise<string> {
return await git(['show', "--format='%h'", 'HEAD', '--quiet']);
}