Skip to content

Commit fd267b0

Browse files
authored
Merge pull request #24 from NaverPayDev/feature/19_fix
[canary-publish] Fix `create_release`-related logic.
2 parents efbad94 + b4cf044 commit fd267b0

File tree

6 files changed

+31
-11
lines changed

6 files changed

+31
-11
lines changed

canary-publish/README.ko.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ jobs:
5050
version_template: '{VERSION}-canary.{DATE}-{COMMITID7}' # (선택) Canary 버전명 템플릿
5151
dry_run: false # (선택) true면 실제 배포 없이 시뮬레이션만 수행
5252
language: 'en' # (선택) 메시지 언어 설정 (en, ko 등)
53-
create_release: false # (선택) true면 Canary 배포 후 GitHub Release 자동 생성
53+
create_release: false # (선택) true면 Canary 배포 후 GitHub Release 자동 생성. 반드시 @action/checkout에 `fetch-depth: 0` with 옵션을 주세요.
5454
```
5555
5656
## 실행 결과

canary-publish/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ jobs:
5050
version_template: '{VERSION}-canary.{DATE}-{COMMITID7}' # (Optional) Template for the canary version string.
5151
dry_run: false # (Optional) If true, performs a dry run without publishing.
5252
language: 'en' # (Optional) Language for output messages (e.g., en, ko).
53-
create_release: false # (Optional) If true, creates a GitHub Release after canary publishing.
53+
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.
5454
```
5555
5656
## Execution Results

canary-publish/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ inputs:
3434
required: false
3535
default: 'false'
3636
create_release:
37-
description: 'create release with package and version'
37+
description: 'create release with package and version (If true, you must set `fetch-depth: 0` in @action/checkout)'
3838
required: false
3939
default: 'false'
4040
language:

canary-publish/dist/index.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53386,7 +53386,12 @@ function main() {
5338653386
language,
5338753387
});
5338853388
const createRelease = core.getBooleanInput('create_release');
53389-
createRelease && (yield (0, publish_1.createReleaseForTags)(publishedPackages.map(({ name, version }) => `${name}@${version}`)));
53389+
createRelease &&
53390+
(yield (0, publish_1.createReleaseForTags)({
53391+
tags: publishedPackages.map(({ name, version }) => `${name}@${version}`),
53392+
baseSha: pullRequestInfo.base.sha,
53393+
headSha: pullRequestInfo.head.sha,
53394+
}));
5339053395
// 배포 완료 코멘트
5339153396
yield issueFetchers.addComment(message);
5339253397
// output 설정
@@ -53397,6 +53402,7 @@ function main() {
5339753402
catch (e) {
5339853403
core.error(e === null || e === void 0 ? void 0 : e.message);
5339953404
issueFetchers.addComment(lang_1.LANGUAGES[language].error);
53405+
process.exit(1); // close with error
5340053406
}
5340153407
});
5340253408
}
@@ -53652,20 +53658,20 @@ function getPublishedPackageInfos({ packagesDir, execOutput, language, }) {
5365253658
publishedPackages: uniqPackages,
5365353659
};
5365453660
}
53655-
function createReleaseForTags(tags) {
53656-
return __awaiter(this, void 0, void 0, function* () {
53661+
function createReleaseForTags(_a) {
53662+
return __awaiter(this, arguments, void 0, function* ({ tags, baseSha, headSha, }) {
5365753663
for (const tag of tags) {
5365853664
// 이미 Release가 생성된 태그는 건너뜀
5365953665
try {
5366053666
yield (0, exec_1.exec)('gh', ['release', 'view', tag]);
5366153667
core.info(`Release already exists for tag: ${tag}`);
5366253668
continue;
5366353669
}
53664-
catch (_a) {
53670+
catch (_b) {
5366553671
// IGNORE: release가 없으면 진행
5366653672
}
5366753673
// 커밋 로그 추출하여 릴리즈 노트 생성
53668-
const notes = (0, node_child_process_1.execSync)(`git log ${tag}^..${tag} --pretty=format:"- %s"`, { encoding: 'utf8' });
53674+
const notes = (0, node_child_process_1.execSync)(`git log ${baseSha}..${headSha} --pretty=format:"- %s"`, { encoding: 'utf8' });
5366953675
/**
5367053676
* GitHub Release 생성
5367153677
* @see https://cli.github.com/manual/gh_release_create

canary-publish/src/index.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,12 @@ async function main() {
148148

149149
const createRelease = core.getBooleanInput('create_release')
150150

151-
createRelease && (await createReleaseForTags(publishedPackages.map(({name, version}) => `${name}@${version}`)))
151+
createRelease &&
152+
(await createReleaseForTags({
153+
tags: publishedPackages.map(({name, version}) => `${name}@${version}`),
154+
baseSha: pullRequestInfo.base.sha,
155+
headSha: pullRequestInfo.head.sha,
156+
}))
152157

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

canary-publish/src/utils/publish.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,15 @@ export function getPublishedPackageInfos({
4343
}
4444
}
4545

46-
export async function createReleaseForTags(tags: string[]) {
46+
export async function createReleaseForTags({
47+
tags,
48+
baseSha,
49+
headSha,
50+
}: {
51+
tags: string[]
52+
baseSha: string
53+
headSha: string
54+
}) {
4755
for (const tag of tags) {
4856
// 이미 Release가 생성된 태그는 건너뜀
4957
try {
@@ -55,7 +63,7 @@ export async function createReleaseForTags(tags: string[]) {
5563
}
5664

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

6068
/**
6169
* GitHub Release 생성

0 commit comments

Comments
 (0)