forked from bluelovers/idea-l10n-zht
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate-git-tag.ts
48 lines (39 loc) · 1.43 KB
/
update-git-tag.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import { gitTag, gitTagSync, IOptions } from '@git-lazy/tag';
import Bluebird from 'bluebird';
import { __root } from '../test/__root';
import micromatch, { not, match } from 'micromatch';
import { console } from 'debug-color2';
import { opts } from '../lib/git/_config';
import { getGitLogs } from '../lib/git/git-logs';
import { join } from 'upath2';
import { updatePluginTag, updateRepoTag } from '../lib/git/git-tag';
import { getSourceInfoSync } from '../lib/build/get-source-info';
import { getBranchInfo } from '../lib/git/branch-info';
export default Bluebird.resolve()
.then(() =>
{
return getGitLogs()
})
.then(async (logs) =>
{
const { isMasterBranch, isVersionBranch } = getBranchInfo();
const __pluginVersion = getSourceInfoSync().pluginMeta.version;
const commit = logs[0];
const bool = /^(?:build\(changelog\): update CHANGELOG|build\(cache\): update publish tags)/.test(commit.subject) || isVersionBranch && commit.subject.startsWith(`build(release): update build`);
const bool2 = match(commit.files, 'CHANGELOG.md').length > 0;
console.cyan.info(commit.abbrevHash, `${commit.subject}`);
console.info(`include CHANGELOG: ${bool} , ${bool2}`);
console.dir(commit.files.length);
if (bool)
{
console.info(`更新 git tag`);
if (isMasterBranch)
{
await updateRepoTag();
}
return updatePluginTag(__pluginVersion)
}
console.warn(`略過本次 git tag 更新`)
})
.catch((e) => console.error(e))
;