Skip to content

[canary-publish] Fix create_release-related logic. #24

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 8, 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
2 changes: 1 addition & 1 deletion canary-publish/README.ko.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
version_template: '{VERSION}-canary.{DATE}-{COMMITID7}' # (선택) Canary 버전명 템플릿
dry_run: false # (선택) true면 실제 배포 없이 시뮬레이션만 수행
language: 'en' # (선택) 메시지 언어 설정 (en, ko 등)
create_release: false # (선택) true면 Canary 배포 후 GitHub Release 자동 생성
create_release: false # (선택) true면 Canary 배포 후 GitHub Release 자동 생성. 반드시 @action/checkout에 `fetch-depth: 0` with 옵션을 주세요.
```

## 실행 결과
Expand Down
2 changes: 1 addition & 1 deletion canary-publish/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
version_template: '{VERSION}-canary.{DATE}-{COMMITID7}' # (Optional) Template for the canary version string.
dry_run: false # (Optional) If true, performs a dry run without publishing.
language: 'en' # (Optional) Language for output messages (e.g., en, ko).
create_release: false # (Optional) If true, creates a GitHub Release after canary publishing.
create_release: false # (Optional) If true, creates a GitHub Release after canary publishing. Make sure to add `fetch-depth: 0` `with` option to @action/checkout.
```

## Execution Results
Expand Down
2 changes: 1 addition & 1 deletion canary-publish/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ inputs:
required: false
default: 'false'
create_release:
description: 'create release with package and version'
description: 'create release with package and version (If true, you must set `fetch-depth: 0` in @action/checkout)'
required: false
default: 'false'
language:
Expand Down
16 changes: 11 additions & 5 deletions canary-publish/dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -53386,7 +53386,12 @@ function main() {
language,
});
const createRelease = core.getBooleanInput('create_release');
createRelease && (yield (0, publish_1.createReleaseForTags)(publishedPackages.map(({ name, version }) => `${name}@${version}`)));
createRelease &&
(yield (0, publish_1.createReleaseForTags)({
tags: publishedPackages.map(({ name, version }) => `${name}@${version}`),
baseSha: pullRequestInfo.base.sha,
headSha: pullRequestInfo.head.sha,
}));
// 배포 완료 코멘트
yield issueFetchers.addComment(message);
// output 설정
Expand All @@ -53397,6 +53402,7 @@ function main() {
catch (e) {
core.error(e === null || e === void 0 ? void 0 : e.message);
issueFetchers.addComment(lang_1.LANGUAGES[language].error);
process.exit(1); // close with error
}
});
}
Expand Down Expand Up @@ -53652,20 +53658,20 @@ function getPublishedPackageInfos({ packagesDir, execOutput, language, }) {
publishedPackages: uniqPackages,
};
}
function createReleaseForTags(tags) {
return __awaiter(this, void 0, void 0, function* () {
function createReleaseForTags(_a) {
return __awaiter(this, arguments, void 0, function* ({ tags, baseSha, headSha, }) {
for (const tag of tags) {
// 이미 Release가 생성된 태그는 건너뜀
try {
yield (0, exec_1.exec)('gh', ['release', 'view', tag]);
core.info(`Release already exists for tag: ${tag}`);
continue;
}
catch (_a) {
catch (_b) {
// IGNORE: release가 없으면 진행
}
// 커밋 로그 추출하여 릴리즈 노트 생성
const notes = (0, node_child_process_1.execSync)(`git log ${tag}^..${tag} --pretty=format:"- %s"`, { encoding: 'utf8' });
const notes = (0, node_child_process_1.execSync)(`git log ${baseSha}..${headSha} --pretty=format:"- %s"`, { encoding: 'utf8' });
/**
* GitHub Release 생성
* @see https://cli.github.com/manual/gh_release_create
Expand Down
8 changes: 7 additions & 1 deletion canary-publish/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,12 @@ async function main() {

const createRelease = core.getBooleanInput('create_release')

createRelease && (await createReleaseForTags(publishedPackages.map(({name, version}) => `${name}@${version}`)))
createRelease &&
(await createReleaseForTags({
tags: publishedPackages.map(({name, version}) => `${name}@${version}`),
baseSha: pullRequestInfo.base.sha,
headSha: pullRequestInfo.head.sha,
}))

// 배포 완료 코멘트
await issueFetchers.addComment(message)
Expand All @@ -160,6 +165,7 @@ async function main() {
} catch (e) {
core.error((e as Error)?.message)
issueFetchers.addComment(LANGUAGES[language].error)
process.exit(1) // close with error
}
}

Expand Down
12 changes: 10 additions & 2 deletions canary-publish/src/utils/publish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,15 @@ export function getPublishedPackageInfos({
}
}

export async function createReleaseForTags(tags: string[]) {
export async function createReleaseForTags({
tags,
baseSha,
headSha,
}: {
tags: string[]
baseSha: string
headSha: string
}) {
for (const tag of tags) {
// 이미 Release가 생성된 태그는 건너뜀
try {
Expand All @@ -55,7 +63,7 @@ export async function createReleaseForTags(tags: string[]) {
}

// 커밋 로그 추출하여 릴리즈 노트 생성
const notes = execSync(`git log ${tag}^..${tag} --pretty=format:"- %s"`, {encoding: 'utf8'})
const notes = execSync(`git log ${baseSha}..${headSha} --pretty=format:"- %s"`, {encoding: 'utf8'})

/**
* GitHub Release 생성
Expand Down