Skip to content

[canary-publish] Check for existing tags before creating and pushing new tags #27

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion canary-publish/dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -53711,13 +53711,32 @@ function createReleaseForTags(_a) {
catch (_b) {
// IGNORE: release가 없으면 진행
}
// 원하는 SHA에 태그가 이미 있는지 확인
let tagExists = false;
try {
// git rev-parse <tag>가 성공하면 이미 태그가 있음
yield (0, exec_1.exec)('git', ['rev-parse', tag]);
tagExists = true;
}
catch (_c) {
tagExists = false;
}
// 태그가 없다면 원하는 SHA에 태그 생성 및 push
if (!tagExists) {
yield (0, exec_1.exec)('git', ['tag', tag, headSha]);
yield (0, exec_1.exec)('git', ['push', 'origin', tag]);
core.info(`Created and pushed tag ${tag} at ${headSha}`);
}
else {
core.info(`Tag ${tag} already exists`);
}
// 커밋 로그 추출하여 릴리즈 노트 생성
const notes = getFilteredCommitMessages({ baseSha, headSha, packagePath, packageName: name });
/**
* GitHub Release 생성
* @see https://cli.github.com/manual/gh_release_create
*/
yield (0, exec_1.exec)('gh', ['release', 'create', tag, '--title', tag, '--notes', notes || 'No changes', '--prerelease']);
yield (0, exec_1.exec)('gh', ['release', 'create', tag, '--title', tag, '--notes', notes, '--prerelease']);
core.info(`Created Release for tag: ${tag}`);
}
});
Expand Down
21 changes: 20 additions & 1 deletion canary-publish/src/utils/publish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,33 @@ export async function createReleaseForTags({
// IGNORE: release가 없으면 진행
}

// 원하는 SHA에 태그가 이미 있는지 확인
let tagExists = false
try {
// git rev-parse <tag>가 성공하면 이미 태그가 있음
await exec('git', ['rev-parse', tag])
tagExists = true
} catch {
tagExists = false
}

// 태그가 없다면 원하는 SHA에 태그 생성 및 push
if (!tagExists) {
await exec('git', ['tag', tag, headSha])
await exec('git', ['push', 'origin', tag])
core.info(`Created and pushed tag ${tag} at ${headSha}`)
} else {
core.info(`Tag ${tag} already exists`)
}

// 커밋 로그 추출하여 릴리즈 노트 생성
const notes = getFilteredCommitMessages({baseSha, headSha, packagePath, packageName: name})

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