Skip to content
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
16 changes: 8 additions & 8 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
### 이슈 <!-- #뒤에 이슈번호 작성 -->
### Issue <!-- Write the issue number after # -->

- NaverPayDev/changeset-actions#

### 작업 유형
### Type of Work

- [ ] 버그 수정
- [ ] 기능 추가
- [ ] 코드 개선
- [ ] Bug Fix
- [ ] Feature Addition
- [ ] Code Improvement

### 작업 내용 <!-- PR의 주요 작업 내용 작성 -->
### Description of Work <!-- Briefly describe the main work done in this PR -->

-
-
-

### PR 포인트 <!-- 리뷰어 분들이 집중적으로 보셨으면 하는 내용 (참고할 내용) -->
### Review Points <!-- Points you want reviewers to focus on (references, details, etc.) -->

-
-
-

### 기타 <!-- 기타 적고싶은 내용(TODO, 참고링크 등) 기재. 없으면 생략 -->
### Others <!-- Any additional notes (TODOs, reference links, etc.). Omit if not applicable -->
16 changes: 10 additions & 6 deletions canary-publish/README.ko.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,16 @@ jobs:
- name: Canary Publish
uses: NaverPayDev/changeset-actions/canary-publish@main
with:
github_token: ${{ secrets.GITHUB_TOKEN }} # 필요하면 user의 PAT을 넣어주세요.
npm_tag: canary # npm 배포 시 달아줄 태그는 무엇으로 할지적어주세요
npm_token: ${{ secrets.NPM_TOKEN }} # npm 배포시 필요한 publish token 을 넣어주세요
publish_script: pnpm run deploy:canary # canary 배포 실행 script 를 넣어주세요
packages_dir: packages # 변경을 탐지할 패키지들의 폴더명을 추가해주세요. (default: packages,share)
excludes: ".turbo,.github" # 변경감지를 제외하고싶은 파일 또는 폴더 경로
github_token: ${{ secrets.GITHUB_TOKEN }} # (필수) GitHub API 인증 토큰. 필요시 사용자 PAT로 대체 가능
npm_tag: canary # (선택) 배포에 사용할 npm 태그 (예: canary, beta 등)
npm_token: ${{ secrets.NPM_TOKEN }} # (필수) npm publish를 위한 인증 토큰
publish_script: pnpm run deploy:canary # (필수) Canary 배포를 실행할 스크립트 명령어
packages_dir: packages # (선택) 변경 감지에 사용할 패키지 디렉터리 (기본값: packages,share)
excludes: ".turbo,.github" # (선택) 변경 감지에서 제외할 파일/디렉터리 목록 (쉼표로 구분)
version_template: '{VERSION}-canary.{DATE}-{COMMITID7}' # (선택) Canary 버전명 템플릿
dry_run: false # (선택) true면 실제 배포 없이 시뮬레이션만 수행
language: 'en' # (선택) 메시지 언어 설정 (en, ko 등)
create_release: false # (선택) true면 Canary 배포 후 GitHub Release 자동 생성
```

## 실행 결과
Expand Down
16 changes: 10 additions & 6 deletions canary-publish/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,16 @@ jobs:
- name: Canary Publish
uses: NaverPayDev/changeset-actions/canary-publish@main
with:
github_token: ${{ secrets.GITHUB_TOKEN }} # Add user PAT if necessary
npm_tag: canary # Specify the npm tag to use for deployment
npm_token: ${{ secrets.NPM_TOKEN }} # Provide the token required for npm publishing
publish_script: pnpm run deploy:canary # Script to execute Canary deployment
packages_dir: packages # Directory of packages to detect changes (default: packages,share)
excludes: ".turbo,.github" # Files or directories to exclude from change detection
github_token: ${{ secrets.GITHUB_TOKEN }} # (Required) GitHub API token for authentication. Use a user PAT if necessary.
npm_tag: canary # (Optional) The npm tag to use for deployment (e.g., canary, beta).
npm_token: ${{ secrets.NPM_TOKEN }} # (Required) Token used for npm publishing.
publish_script: pnpm run deploy:canary # (Required) Script command to execute the canary deployment.
packages_dir: packages # (Optional) Directory containing packages to check for changes (default: packages,share).
excludes: ".turbo,.github" # (Optional) Files or directories to exclude from change detection (comma-separated).
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.
```

## Execution Results
Expand Down
42 changes: 29 additions & 13 deletions canary-publish/action.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,43 @@
name: "changesets-canary-publish"
description: "changesets canary publish"
name: 'changesets-canary-publish'
description: 'changesets canary publish'
runs:
using: "node16"
main: "dist/index.js"
using: 'node16'
main: 'dist/index.js'
inputs:
github_token:
description: "github token"
description: 'github token'
required: true
npm_tag:
description: "npm tag"
description: 'npm tag'
default: canary
required: false
npm_token:
description: "npm token"
description: 'npm token'
required: true
publish_script:
description: "canary deploy script"
description: 'canary deploy script'
required: true
packages_dir:
description: "패키지 디렉터리"
description: '패키지 디렉터리'
required: false
default: "packages,share"
excludes:
description: "제외할 경로"
default: 'packages,share'
excludes:
description: '제외할 경로'
required: false
default: ".github,.changeset"
default: '.github,.changeset'
version_template:
description: 'package version template for canary (variables: VERSION, DATE, COMMITID7)'
required: false
default: '{VERSION}-canary-{COMMITID7}'
dry_run:
description: 'only log packages to canary without publishing'
required: false
default: 'false'
create_release:
description: 'create release with package and version'
required: false
default: 'false'
language:
description: 'language for release note, comment etc.'
required: false
default: 'en'
143 changes: 133 additions & 10 deletions canary-publish/dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -53204,6 +53204,29 @@ function Node (value, prev, next, list) {
}


/***/ }),

/***/ 5264:
/***/ ((__unused_webpack_module, exports) => {

"use strict";

Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.LANGUAGES = void 0;
exports.LANGUAGES = {
en: {
empty: 'No changed files exist under the {PATH} path, no packages have been deployed.',
error: 'An error occurred during the canary deployment.',
failure: 'Please specify the detect version for a valid canary version deployment',
},
ko: {
empty: '{PATH} 하위 변경된 파일이 없어, 배포된 패키지가 없습니다.',
error: '카나리 배포 도중 에러가 발생했습니다.',
failure: '올바른 카나리 버전 배포를 위해 detect version을 명시해주세요',
},
};


/***/ }),

/***/ 7630:
Expand Down Expand Up @@ -53250,6 +53273,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
const core = __importStar(__nccwpck_require__(6108));
const exec_1 = __nccwpck_require__(9629);
const read_1 = __importDefault(__nccwpck_require__(1746));
const lang_1 = __nccwpck_require__(5264);
const fs = __importStar(__nccwpck_require__(77));
const resolve_from_1 = __importDefault(__nccwpck_require__(1345));
const apis_1 = __importDefault(__nccwpck_require__(6500));
Expand All @@ -53258,19 +53282,25 @@ const file_1 = __nccwpck_require__(398);
const npm_1 = __nccwpck_require__(6824);
const publish_1 = __nccwpck_require__(9459);
const cwd = process.cwd();
const VERSION_TEMPLATE_CONSTANTS = {
version: 'VERSION',
date: 'DATE',
commitId7: 'COMMITID7',
};
function main() {
return __awaiter(this, void 0, void 0, function* () {
var _a;
// npmrc 설정
yield (0, npm_1.setNpmRc)();
const { pullFetchers, issueFetchers } = (0, apis_1.default)();
const pullRequestInfo = yield pullFetchers.getPullRequestInfo();
const language = core.getInput('language');
try {
// 변경된 사항이 있는지 체크.
// 변경사항이 있을때만 카나리를 배포 할 수 있다.
const changesets = yield (0, read_1.default)(cwd);
if (changesets.length === 0) {
yield issueFetchers.addComment('올바른 카나리 버전 배포를 위해 detect version을 명시해주세요');
yield issueFetchers.addComment(lang_1.LANGUAGES[language].failure);
return;
}
const changedFiles = yield (0, utils_1.getChangedAllFiles)({
Expand Down Expand Up @@ -53315,14 +53345,35 @@ function main() {
}
}
fs.writeFileSync(rootPackageJsonPath, JSON.stringify(rootPackageJson, null, 2), 'utf8');
const versionTemplate = core.getInput('version_template');
// 변경된 패키지들의 버전을 강제로 치환합니다
changedPackageInfos.forEach((packageJsonPath) => {
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
const newVersion = `${packageJson.version}-${npmTag}-${pullRequestInfo.head.sha.slice(0, 7)}`;
core.info(`✅ [${packageJson.name}] 이전 버전: ${packageJson.version} / 😘 새로운 버전: ${newVersion}`);
const today = new Date();
const pad = (n) => n.toString().padStart(2, '0');
const year2 = today.getFullYear().toString().slice(2);
const dateStr = `${year2}${pad(today.getMonth() + 1)}${pad(today.getDate())}`; // YYYYMMDD
const commitId7 = pullRequestInfo.head.sha.slice(0, 7);
const version = packageJson.version;
const replacements = {
[VERSION_TEMPLATE_CONSTANTS.version]: version,
[VERSION_TEMPLATE_CONSTANTS.date]: dateStr,
[VERSION_TEMPLATE_CONSTANTS.commitId7]: commitId7,
};
const templateConstantsString = Object.values(VERSION_TEMPLATE_CONSTANTS).join('|');
const newVersion = versionTemplate.replace(new RegExp(`\\{(${templateConstantsString})\\}`, 'g'), (_, key) => {
var _a;
return (_a = replacements[key]) !== null && _a !== void 0 ? _a : '';
});
core.info(`✅ [${packageJson.name}] Previous version: ${packageJson.version} / 😘 Next version: ${newVersion}`);
packageJson.version = newVersion;
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2), 'utf8');
});
const dryRun = core.getBooleanInput('dry_run');
if (dryRun) {
core.info('This is dry run for Canary distribution.');
return;
}
// 변경된 버전으로 카나리 배포
const publishScript = core.getInput('publish_script');
const [publishCommand, ...publishArgs] = publishScript.split(/\s+/);
Expand All @@ -53332,7 +53383,10 @@ function main() {
const { message, publishedPackages } = (0, publish_1.getPublishedPackageInfos)({
execOutput: changesetPublishOutput,
packagesDir,
language,
});
const createRelease = core.getBooleanInput('create_release');
createRelease && (yield (0, publish_1.createReleaseForTags)(publishedPackages.map(({ name, version }) => `${name}@${version}`)));
// 배포 완료 코멘트
yield issueFetchers.addComment(message);
// output 설정
Expand All @@ -53341,7 +53395,8 @@ function main() {
core.setOutput('message', message);
}
catch (e) {
issueFetchers.addComment('카나리 배포 도중 에러가 발생했습니다.');
core.error(e === null || e === void 0 ? void 0 : e.message);
issueFetchers.addComment(lang_1.LANGUAGES[language].error);
}
});
}
Expand Down Expand Up @@ -53435,7 +53490,7 @@ function protectUnchangedPackages(changedPackages) {
for (const packageJsonPath of allPackageJSON) {
if (!changedPackages.includes(packageJsonPath)) {
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
core.info(`🔨 [${packageJson.name}] private:true 를 추가합니다`);
core.info(`🔨 [${packageJson.name}] Add private:true option.`);
packageJson.private = true;
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2), 'utf8');
}
Expand All @@ -53447,7 +53502,7 @@ function removeChangesetMdFiles(_a) {
const markdownPaths = yield (0, fast_glob_1.default)('.changeset/*.md');
return Promise.all(markdownPaths.map((markdownPath) => __awaiter(this, void 0, void 0, function* () {
if (changedFiles.find(({ filename }) => filename === markdownPath) == null) {
console.log(`PR과 관련없는 ${markdownPath} 제거`); // eslint-disable-line
console.log(`Remove ${markdownPath} unrelated to PR`); // eslint-disable-line
yield fs.remove(markdownPath);
}
})));
Expand Down Expand Up @@ -53528,18 +53583,55 @@ function setNpmRc() {
/***/ }),

/***/ 9459:
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {

"use strict";

var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.getPublishedPackageInfos = getPublishedPackageInfos;
exports.createReleaseForTags = createReleaseForTags;
const node_child_process_1 = __nccwpck_require__(7718);
const core = __importStar(__nccwpck_require__(6108));
const exec_1 = __nccwpck_require__(9629);
const lang_1 = __nccwpck_require__(5264);
const utils_1 = __nccwpck_require__(3927);
function getPublishedPackageInfos({ packagesDir, execOutput }) {
function getPublishedPackageInfos({ packagesDir, execOutput, language, }) {
const publishedPackages = [];
for (const publishOutput of execOutput.stdout.split('\n')) {
// eslint-disable-next-line no-useless-escape
const regExp = /^(🦋 {2})([A-Za-z-\d\/\@]+@)(\d+\.\d+\.\d+\-[A-Za-z]+\-\w{7})$/;
const regExp = /^(🦋 {2})([A-Za-z-\d\/\@]+@)(.+)$/;
const matchResult = publishOutput.trim().match(regExp);
if (!matchResult) {
continue;
Expand All @@ -53551,12 +53643,35 @@ function getPublishedPackageInfos({ packagesDir, execOutput }) {
const copyCodeBlock = uniqPackages.map(({ name, version }) => `${name}@${version}`).join('\n');
const message = uniqPackages.length > 0
? ['## Published Canary Packages', '', '', '```', `${copyCodeBlock}`, '```'].join('\n')
: `${packagesDir} 하위 변경된 파일이 없어, 배포된 패키지가 없습니다.`;
: lang_1.LANGUAGES[language].empty.replace('{PATH}', packagesDir);
return {
message,
publishedPackages: uniqPackages,
};
}
function createReleaseForTags(tags) {
return __awaiter(this, void 0, void 0, function* () {
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) {
// IGNORE: release가 없으면 진행
}
// 커밋 로그 추출하여 릴리즈 노트 생성
const notes = (0, node_child_process_1.execSync)(`git log ${tag}^..${tag} --pretty=format:"- %s"`, { encoding: 'utf8' });
/**
* 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']);
core.info(`Created Release for tag: ${tag}`);
}
});
}


/***/ }),
Expand Down Expand Up @@ -54154,6 +54269,14 @@ module.exports = require("net");

/***/ }),

/***/ 7718:
/***/ ((module) => {

"use strict";
module.exports = require("node:child_process");

/***/ }),

/***/ 5673:
/***/ ((module) => {

Expand Down
Loading