Skip to content

Commit 8ee91e7

Browse files
authored
Merge pull request #26 from NaverPayDev/feature/19_fix
[canary-publish] Enhance release notes with package details
2 parents 8003e84 + d088f76 commit 8ee91e7

File tree

3 files changed

+61
-15
lines changed

3 files changed

+61
-15
lines changed

canary-publish/dist/index.js

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53270,6 +53270,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5327053270
return (mod && mod.__esModule) ? mod : { "default": mod };
5327153271
};
5327253272
Object.defineProperty(exports, "__esModule", ({ value: true }));
53273+
const node_path_1 = __nccwpck_require__(9411);
5327353274
const core = __importStar(__nccwpck_require__(6108));
5327453275
const exec_1 = __nccwpck_require__(9629);
5327553276
const read_1 = __importDefault(__nccwpck_require__(1746));
@@ -53346,6 +53347,7 @@ function main() {
5334653347
}
5334753348
fs.writeFileSync(rootPackageJsonPath, JSON.stringify(rootPackageJson, null, 2), 'utf8');
5334853349
const versionTemplate = core.getInput('version_template');
53350+
const packagePathByName = {};
5334953351
// 변경된 패키지들의 버전을 강제로 치환합니다
5335053352
changedPackageInfos.forEach((packageJsonPath) => {
5335153353
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
@@ -53367,6 +53369,7 @@ function main() {
5336753369
});
5336853370
core.info(`✅ [${packageJson.name}] Previous version: ${packageJson.version} / 😘 Next version: ${newVersion}`);
5336953371
packageJson.version = newVersion;
53372+
packagePathByName[packageJson.name] = (0, node_path_1.dirname)(packageJsonPath);
5337053373
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2), 'utf8');
5337153374
});
5337253375
const dryRun = core.getBooleanInput('dry_run');
@@ -53388,7 +53391,12 @@ function main() {
5338853391
const createRelease = core.getBooleanInput('create_release');
5338953392
createRelease &&
5339053393
(yield (0, publish_1.createReleaseForTags)({
53391-
tags: publishedPackages.map(({ name, version }) => `${name}@${version}`),
53394+
packageData: publishedPackages.map(({ name, version }) => ({
53395+
name,
53396+
version,
53397+
tag: `${name}@${version}`,
53398+
packagePath: packagePathByName[name],
53399+
})),
5339253400
baseSha: pullRequestInfo.base.sha,
5339353401
headSha: pullRequestInfo.head.sha,
5339453402
}));
@@ -53661,15 +53669,17 @@ function getPublishedPackageInfos({ packagesDir, execOutput, language, }) {
5366153669
/**
5366253670
* changeset 변경 파일 커밋만 제외하고 작업 커밋 로그만 추출
5366353671
*/
53664-
function getFilteredCommitMessages({ baseSha, headSha }) {
53672+
function getFilteredCommitMessages({ baseSha, headSha, packagePath, packageName, }) {
5366553673
// 커밋 해시 목록만 추출
53666-
const shas = (0, node_child_process_1.execSync)(`git log --reverse --pretty=format:"%H" ${baseSha}..${headSha}`, { encoding: 'utf8' })
53674+
const shas = (0, node_child_process_1.execSync)(`git log --reverse --pretty=format:"%H" ${baseSha}..${headSha} -- ${packagePath}`, {
53675+
encoding: 'utf8',
53676+
})
5366753677
.split('\n')
5366853678
.filter(Boolean);
5366953679
const messages = [
5367053680
'## 🚧 Pre-release',
5367153681
'',
53672-
`This release is a **pre-release** version.`,
53682+
`This release is a **pre-release** version of ${packageName}.`,
5367353683
'Please make sure to thoroughly test it before deploying to production.',
5367453684
'',
5367553685
'### Changes',
@@ -53690,8 +53700,8 @@ function getFilteredCommitMessages({ baseSha, headSha }) {
5369053700
return messages.join('\n');
5369153701
}
5369253702
function createReleaseForTags(_a) {
53693-
return __awaiter(this, arguments, void 0, function* ({ tags, baseSha, headSha, }) {
53694-
for (const tag of tags) {
53703+
return __awaiter(this, arguments, void 0, function* ({ packageData, baseSha, headSha, }) {
53704+
for (const { tag, packagePath, name } of packageData) {
5369553705
// 이미 Release가 생성된 태그는 건너뜀
5369653706
try {
5369753707
yield (0, exec_1.exec)('gh', ['release', 'view', tag]);
@@ -53702,7 +53712,7 @@ function createReleaseForTags(_a) {
5370253712
// IGNORE: release가 없으면 진행
5370353713
}
5370453714
// 커밋 로그 추출하여 릴리즈 노트 생성
53705-
const notes = getFilteredCommitMessages({ baseSha, headSha });
53715+
const notes = getFilteredCommitMessages({ baseSha, headSha, packagePath, packageName: name });
5370653716
/**
5370753717
* GitHub Release 생성
5370853718
* @see https://cli.github.com/manual/gh_release_create
@@ -54325,6 +54335,14 @@ module.exports = require("node:events");
5432554335

5432654336
/***/ }),
5432754337

54338+
/***/ 9411:
54339+
/***/ ((module) => {
54340+
54341+
"use strict";
54342+
module.exports = require("node:path");
54343+
54344+
/***/ }),
54345+
5432854346
/***/ 4492:
5432954347
/***/ ((module) => {
5433054348

canary-publish/src/index.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import {dirname} from 'node:path'
2+
13
import * as core from '@actions/core'
24
import {exec, getExecOutput} from '@actions/exec'
35
import readChangesets from '@changesets/read'
@@ -91,6 +93,8 @@ async function main() {
9193

9294
const versionTemplate = core.getInput('version_template')
9395

96+
const packagePathByName: Record<string, string> = {}
97+
9498
// 변경된 패키지들의 버전을 강제로 치환합니다
9599
changedPackageInfos.forEach((packageJsonPath) => {
96100
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'))
@@ -122,6 +126,8 @@ async function main() {
122126

123127
packageJson.version = newVersion
124128

129+
packagePathByName[packageJson.name] = dirname(packageJsonPath)
130+
125131
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2), 'utf8')
126132
})
127133

@@ -150,7 +156,12 @@ async function main() {
150156

151157
createRelease &&
152158
(await createReleaseForTags({
153-
tags: publishedPackages.map(({name, version}) => `${name}@${version}`),
159+
packageData: publishedPackages.map(({name, version}) => ({
160+
name,
161+
version,
162+
tag: `${name}@${version}`,
163+
packagePath: packagePathByName[name],
164+
})),
154165
baseSha: pullRequestInfo.base.sha,
155166
headSha: pullRequestInfo.head.sha,
156167
}))

canary-publish/src/utils/publish.ts

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,28 @@ export function getPublishedPackageInfos({
4646
/**
4747
* changeset 변경 파일 커밋만 제외하고 작업 커밋 로그만 추출
4848
*/
49-
function getFilteredCommitMessages({baseSha, headSha}: {baseSha: string; headSha: string}) {
49+
function getFilteredCommitMessages({
50+
baseSha,
51+
headSha,
52+
packagePath,
53+
packageName,
54+
}: {
55+
baseSha: string
56+
headSha: string
57+
packagePath: string
58+
packageName: string
59+
}) {
5060
// 커밋 해시 목록만 추출
51-
const shas = execSync(`git log --reverse --pretty=format:"%H" ${baseSha}..${headSha}`, {encoding: 'utf8'})
61+
const shas = execSync(`git log --reverse --pretty=format:"%H" ${baseSha}..${headSha} -- ${packagePath}`, {
62+
encoding: 'utf8',
63+
})
5264
.split('\n')
5365
.filter(Boolean)
5466

5567
const messages = [
5668
'## 🚧 Pre-release',
5769
'',
58-
`This release is a **pre-release** version.`,
70+
`This release is a **pre-release** version of ${packageName}.`,
5971
'Please make sure to thoroughly test it before deploying to production.',
6072
'',
6173
'### Changes',
@@ -81,15 +93,20 @@ function getFilteredCommitMessages({baseSha, headSha}: {baseSha: string; headSha
8193
}
8294

8395
export async function createReleaseForTags({
84-
tags,
96+
packageData,
8597
baseSha,
8698
headSha,
8799
}: {
88-
tags: string[]
100+
packageData: {
101+
name: string
102+
version: string
103+
tag: string
104+
packagePath: string
105+
}[]
89106
baseSha: string
90107
headSha: string
91108
}) {
92-
for (const tag of tags) {
109+
for (const {tag, packagePath, name} of packageData) {
93110
// 이미 Release가 생성된 태그는 건너뜀
94111
try {
95112
await exec('gh', ['release', 'view', tag])
@@ -100,7 +117,7 @@ export async function createReleaseForTags({
100117
}
101118

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

105122
/**
106123
* GitHub Release 생성

0 commit comments

Comments
 (0)