feat: Use native GitHub Action tools to download assets and use GitHub API (#187)

* Use native GitHub Action tools to download assets and use GitHub API
* Fix unexpected output when tag not found
* Use GitHub Action exec
* Add screenshot

Co-authored-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax
2020-05-07 02:15:24 +02:00
committed by GitHub
parent 88f1da8c86
commit 6c7b10c265
16 changed files with 269 additions and 23170 deletions
+15 -13
View File
@@ -1,12 +1,22 @@
import * as child_process from 'child_process';
import * as exec from './exec';
const git = async (args: string[] = []) => {
const stdout = child_process.execSync(`git ${args.join(' ')}`, {
encoding: 'utf8'
const git = async (args: string[] = []): Promise<string> => {
return await exec.exec(`git`, args, true).then(res => {
if (res.stderr != '' && !res.success) {
throw new Error(res.stderr);
}
return res.stdout.trim();
});
return stdout.trim();
};
export async function getTag(): Promise<string> {
try {
return await git(['describe', '--tags', '--abbrev=0']);
} catch (err) {
return '';
}
}
export async function isTagDirty(currentTag: string): Promise<boolean> {
try {
await git(['describe', '--exact-match', '--tags', '--match', currentTag]);
@@ -16,14 +26,6 @@ export async function isTagDirty(currentTag: string): Promise<boolean> {
return false;
}
export async function getTag(): Promise<string> {
try {
return await git(['describe', '--tags', '--abbrev=0']);
} catch (err) {
return '';
}
}
export async function getShortCommit(): Promise<string> {
return await git(['show', "--format='%h'", 'HEAD', '--quiet']);
}