Skip to content

Commit de9941c

Browse files
author
fanwenjie
committed
chore: better logic
1 parent afe7ea5 commit de9941c

File tree

3 files changed

+28
-11
lines changed

3 files changed

+28
-11
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"changes": [
3+
{
4+
"packageName": "@coze-arch/rush-publish-plugin",
5+
"comment": "better logic",
6+
"type": "patch"
7+
}
8+
],
9+
"packageName": "@coze-arch/rush-publish-plugin",
10+
"email": "tecvan.fe@gmail.com"
11+
}

packages/rush-plugins/publish/src/action/publish/git.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,24 +26,29 @@ interface CommitChangesOptions {
2626
cwd: string;
2727
publishManifests: PublishManifest[];
2828
branchName: string;
29+
createTags: boolean;
2930
}
3031
export async function commitChanges({
3132
sessionId,
3233
files,
3334
cwd,
3435
publishManifests,
3536
branchName,
37+
createTags,
3638
}: CommitChangesOptions): Promise<{ effects: string[]; branchName: string }> {
3739
await exec(`git add ${files.join(' ')}`, { cwd });
3840
await exec(`git commit -m "chore: Publish ${branchName}" -n`, { cwd });
3941

40-
const tags = publishManifests.map(
41-
m => `v/${m.project.packageName}@${m.newVersion}`,
42-
);
43-
await exec(
44-
tags.map(tag => `git tag -a ${tag} -m "Bump type ${tag}"`).join(' && '),
45-
{ cwd },
46-
);
42+
let tags: string[] = [];
43+
if (createTags) {
44+
tags = publishManifests.map(
45+
m => `v/${m.project.packageName}@${m.newVersion}`,
46+
);
47+
await exec(
48+
tags.map(tag => `git tag -a ${tag} -m "Bump type ${tag}"`).join(' && '),
49+
{ cwd },
50+
);
51+
}
4752
return { effects: [...tags, branchName], branchName };
4853
}
4954

packages/rush-plugins/publish/src/action/publish/push-to-remote.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ export const pushToRemote = async (options: PushToRemoteOptions) => {
4444
branchName = `release/${date}-${sessionId}`;
4545
await exec(`git checkout -b ${branchName}`, { cwd });
4646
}
47+
const isTestPublish = [BumpType.ALPHA, BumpType.BETA].includes(
48+
bumpPolicy as BumpType,
49+
);
4750

4851
// 4. 创建并推送发布分支
4952
const { effects } = await commitChanges({
@@ -52,6 +55,8 @@ export const pushToRemote = async (options: PushToRemoteOptions) => {
5255
cwd,
5356
publishManifests,
5457
branchName,
58+
// 只有 alpha、beta 需要创建 tag,正式发布会在 .github/workflows/common-pr-checks.yml 创建并发布tag
59+
createTags: isTestPublish,
5560
});
5661
if (skipPush) {
5762
return;
@@ -62,10 +67,6 @@ export const pushToRemote = async (options: PushToRemoteOptions) => {
6267
repoUrl: actualRepoUrl,
6368
});
6469

65-
const isTestPublish = [BumpType.ALPHA, BumpType.BETA].includes(
66-
bumpPolicy as BumpType,
67-
);
68-
6970
// 从 git URL 提取组织和仓库名称,用于构建 GitHub 链接
7071
const repoInfoMatch = actualRepoUrl.match(GIT_REPO_URL_REGEX);
7172
if (!repoInfoMatch) {

0 commit comments

Comments
 (0)