Skip to content

Commit 0077b3f

Browse files
authored
Merge pull request #27 from NaverPayDev/feature/19_fix
[canary-publish] Check for existing tags before creating and pushing new tags
2 parents 8ee91e7 + 4bb01f6 commit 0077b3f

File tree

2 files changed

+40
-2
lines changed

2 files changed

+40
-2
lines changed

canary-publish/dist/index.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53711,13 +53711,32 @@ function createReleaseForTags(_a) {
5371153711
catch (_b) {
5371253712
// IGNORE: release가 없으면 진행
5371353713
}
53714+
// 원하는 SHA에 태그가 이미 있는지 확인
53715+
let tagExists = false;
53716+
try {
53717+
// git rev-parse <tag>가 성공하면 이미 태그가 있음
53718+
yield (0, exec_1.exec)('git', ['rev-parse', tag]);
53719+
tagExists = true;
53720+
}
53721+
catch (_c) {
53722+
tagExists = false;
53723+
}
53724+
// 태그가 없다면 원하는 SHA에 태그 생성 및 push
53725+
if (!tagExists) {
53726+
yield (0, exec_1.exec)('git', ['tag', tag, headSha]);
53727+
yield (0, exec_1.exec)('git', ['push', 'origin', tag]);
53728+
core.info(`Created and pushed tag ${tag} at ${headSha}`);
53729+
}
53730+
else {
53731+
core.info(`Tag ${tag} already exists`);
53732+
}
5371453733
// 커밋 로그 추출하여 릴리즈 노트 생성
5371553734
const notes = getFilteredCommitMessages({ baseSha, headSha, packagePath, packageName: name });
5371653735
/**
5371753736
* GitHub Release 생성
5371853737
* @see https://cli.github.com/manual/gh_release_create
5371953738
*/
53720-
yield (0, exec_1.exec)('gh', ['release', 'create', tag, '--title', tag, '--notes', notes || 'No changes', '--prerelease']);
53739+
yield (0, exec_1.exec)('gh', ['release', 'create', tag, '--title', tag, '--notes', notes, '--prerelease']);
5372153740
core.info(`Created Release for tag: ${tag}`);
5372253741
}
5372353742
});

canary-publish/src/utils/publish.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,14 +116,33 @@ export async function createReleaseForTags({
116116
// IGNORE: release가 없으면 진행
117117
}
118118

119+
// 원하는 SHA에 태그가 이미 있는지 확인
120+
let tagExists = false
121+
try {
122+
// git rev-parse <tag>가 성공하면 이미 태그가 있음
123+
await exec('git', ['rev-parse', tag])
124+
tagExists = true
125+
} catch {
126+
tagExists = false
127+
}
128+
129+
// 태그가 없다면 원하는 SHA에 태그 생성 및 push
130+
if (!tagExists) {
131+
await exec('git', ['tag', tag, headSha])
132+
await exec('git', ['push', 'origin', tag])
133+
core.info(`Created and pushed tag ${tag} at ${headSha}`)
134+
} else {
135+
core.info(`Tag ${tag} already exists`)
136+
}
137+
119138
// 커밋 로그 추출하여 릴리즈 노트 생성
120139
const notes = getFilteredCommitMessages({baseSha, headSha, packagePath, packageName: name})
121140

122141
/**
123142
* GitHub Release 생성
124143
* @see https://cli.github.com/manual/gh_release_create
125144
*/
126-
await exec('gh', ['release', 'create', tag, '--title', tag, '--notes', notes || 'No changes', '--prerelease'])
145+
await exec('gh', ['release', 'create', tag, '--title', tag, '--notes', notes, '--prerelease'])
127146
core.info(`Created Release for tag: ${tag}`)
128147
}
129148
}

0 commit comments

Comments
 (0)