Skip to content

Commit 58f58ba

Browse files
committed
feat: implement independent package release system
- Configure Changesets for independent package versioning - Add release:packages script for fault-tolerant deployments - Update workflows to support individual package build failures - Each package can now be released independently
1 parent 4080c0c commit 58f58ba

File tree

5 files changed

+111
-10
lines changed

5 files changed

+111
-10
lines changed

.changeset/config.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33
"changelog": "@changesets/cli/changelog",
44
"commit": false,
55
"fixed": [],
6-
"linked": [
7-
["vue-pivottable", "@vue-pivottable/*"]
8-
],
6+
"linked": [],
97
"access": "public",
108
"baseBranch": "main",
119
"updateInternalDependencies": "patch",

.changeset/initial-changesets-setup.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
---
22
"vue-pivottable": patch
3-
"@vue-pivottable/lazy-table-renderer": patch
4-
"@vue-pivottable/plotly-renderer": patch
53
---
64

75
chore: implement Changesets for monorepo release management

.github/workflows/release.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,23 +45,21 @@ jobs:
4545
- name: Install dependencies
4646
run: pnpm install
4747

48-
- name: Build all packages
49-
run: pnpm build:all
50-
5148
- name: Create Release Pull Request or Publish
5249
id: changesets
5350
uses: changesets/action@v1
5451
with:
5552
# This will create a PR with version bumps and changelog updates
5653
# When the PR is merged, it will publish to npm
57-
publish: pnpm changeset publish
54+
publish: pnpm release:packages
5855
version: pnpm changeset version
5956
commit: "chore: release packages"
6057
title: "chore: release packages"
6158
createGithubReleases: true
6259
env:
6360
GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }}
6461
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
62+
NPM_TOKEN_SUMIN: ${{ secrets.NPM_TOKEN_SUMIN }}
6563

6664
# Alternative: Use semantic-release with GitHub App token
6765
# - name: Release

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@
6161
"dev:all": "concurrently \"pnpm dev\" \"pnpm -r --parallel run dev\"",
6262
"changeset": "changeset",
6363
"version-packages": "changeset version",
64-
"release": "pnpm build:all && changeset publish"
64+
"release": "pnpm build:all && changeset publish",
65+
"release:packages": "node scripts/release-packages.js"
6566
},
6667
"peerDependencies": {
6768
"vue": "^3.2.0"

scripts/release-packages.js

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
#!/usr/bin/env node
2+
3+
/**
4+
* 독립적인 패키지 배포 스크립트
5+
* 각 패키지를 개별적으로 빌드하고 배포합니다.
6+
* 하나가 실패해도 다른 패키지는 계속 진행됩니다.
7+
*/
8+
9+
const { execSync } = require('child_process');
10+
const fs = require('fs');
11+
const path = require('path');
12+
13+
// 패키지 목록
14+
const packages = [
15+
{
16+
name: 'vue-pivottable',
17+
path: '.',
18+
buildCmd: 'pnpm build',
19+
npmToken: 'NPM_TOKEN'
20+
},
21+
{
22+
name: '@vue-pivottable/lazy-table-renderer',
23+
path: 'packages/lazy-table-renderer',
24+
buildCmd: 'pnpm -F @vue-pivottable/lazy-table-renderer build',
25+
npmToken: 'NPM_TOKEN'
26+
},
27+
{
28+
name: '@vue-pivottable/plotly-renderer',
29+
path: 'packages/plotly-renderer',
30+
buildCmd: 'pnpm -F @vue-pivottable/plotly-renderer build',
31+
npmToken: 'NPM_TOKEN_SUMIN'
32+
}
33+
];
34+
35+
// 색상 출력을 위한 헬퍼
36+
const colors = {
37+
green: (text) => `\x1b[32m${text}\x1b[0m`,
38+
red: (text) => `\x1b[31m${text}\x1b[0m`,
39+
yellow: (text) => `\x1b[33m${text}\x1b[0m`,
40+
blue: (text) => `\x1b[34m${text}\x1b[0m`
41+
};
42+
43+
// 각 패키지 처리
44+
async function releasePackages() {
45+
const results = [];
46+
47+
for (const pkg of packages) {
48+
console.log(colors.blue(`\n🚀 Processing ${pkg.name}...`));
49+
50+
// 빌드 시도
51+
try {
52+
console.log(colors.yellow(` Building ${pkg.name}...`));
53+
execSync(pkg.buildCmd, { stdio: 'inherit' });
54+
console.log(colors.green(` ✅ Build successful`));
55+
} catch (error) {
56+
console.log(colors.red(` ❌ Build failed for ${pkg.name}`));
57+
results.push({ package: pkg.name, status: 'build failed' });
58+
continue; // 다음 패키지로 진행
59+
}
60+
61+
// 배포 시도
62+
try {
63+
console.log(colors.yellow(` Publishing ${pkg.name}...`));
64+
65+
// 올바른 NPM 토큰 설정
66+
const npmToken = process.env[pkg.npmToken];
67+
if (!npmToken) {
68+
throw new Error(`${pkg.npmToken} not found in environment`);
69+
}
70+
71+
// changeset publish 실행
72+
const publishCmd = `cd ${pkg.path} && NPM_TOKEN=${npmToken} pnpm changeset publish`;
73+
execSync(publishCmd, {
74+
stdio: 'inherit',
75+
env: { ...process.env, NPM_TOKEN: npmToken }
76+
});
77+
78+
console.log(colors.green(` ✅ Published successfully`));
79+
results.push({ package: pkg.name, status: 'success' });
80+
} catch (error) {
81+
console.log(colors.red(` ❌ Publish failed for ${pkg.name}`));
82+
results.push({ package: pkg.name, status: 'publish failed' });
83+
}
84+
}
85+
86+
// 결과 요약
87+
console.log(colors.blue('\n📊 Release Summary:'));
88+
results.forEach(result => {
89+
const icon = result.status === 'success' ? '✅' : '❌';
90+
const color = result.status === 'success' ? colors.green : colors.red;
91+
console.log(` ${icon} ${result.package}: ${color(result.status)}`);
92+
});
93+
94+
// 하나라도 실패했으면 exit code 1 반환 (optional)
95+
const hasFailures = results.some(r => r.status !== 'success');
96+
if (hasFailures) {
97+
console.log(colors.yellow('\n⚠️ Some packages failed, but others were published successfully'));
98+
// process.exit(1); // CI에서 실패로 표시하려면 주석 해제
99+
}
100+
}
101+
102+
// 실행
103+
releasePackages().catch(error => {
104+
console.error(colors.red('Unexpected error:'), error);
105+
process.exit(1);
106+
});

0 commit comments

Comments
 (0)