Skip to content

Commit 8ccfb32

Browse files
committed
infra: enhance release process
1 parent 258374a commit 8ccfb32

34 files changed

Lines changed: 4129 additions & 1760 deletions

infra/pdk/README.md

Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
<p align="center">
2+
<h1 align="center">pnpm-dev-kit</h1>
3+
<p align="center">
4+
<a href="https://www.npmjs.com/package/pnpm-dev-kit"><img src="https://img.shields.io/npm/v/pnpm-dev-kit.svg?style=flat-square" alt="npm version"></a>
5+
<a href="https://www.npmjs.com/package/pnpm-dev-kit"><img src="https://img.shields.io/npm/dm/pnpm-dev-kit.svg?style=flat-square" alt="npm downloads"></a>
6+
<a href="https://github.com/license"><img src="https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square" alt="license"></a>
7+
</p>
8+
<p align="center">PDK - PNPM Dev Kit, An efficient PNPM workspace development and publishing tool.</p>
9+
</p>
10+
11+
## Features
12+
13+
- 💻 **Dev Mode**: Quickly launch on-demand development builds for monorepo packages
14+
- 🚀 **Release Management**: Automated version bumping and publishing
15+
- 🔧 **Patch System**: Repair failed package publications
16+
- 📝 **Changelog Generation**: Automatic, customizable changelog creation
17+
- 🏷️ **GitHub Release**: Automatic GitHub release creation with changelog extraction
18+
19+
## Install
20+
21+
```bash
22+
# Using npm
23+
npm install --save-dev pnpm-dev-kit
24+
25+
# Using yarn
26+
yarn add --dev pnpm-dev-kit
27+
28+
# Using pnpm
29+
pnpm add -D pnpm-dev-kit
30+
```
31+
32+
For global installation:
33+
34+
```bash
35+
npm install -g pnpm-dev-kit
36+
```
37+
38+
## Usage
39+
40+
### Development Mode
41+
42+
Quickly start development mode to build packages on demand when files change:
43+
44+
```bash
45+
# Using the CLI
46+
pdk dev
47+
48+
# Or with npm script
49+
npm run dev
50+
```
51+
52+
**Interactive Features:**
53+
54+
- Type `n` to select a package to build manually
55+
- Type `ps` to list running processes
56+
- Type package name to build a specific package
57+
58+
### Release Process
59+
60+
**Standard Release:**
61+
```bash
62+
# Complete release (recommended)
63+
pdk release --push-tag --create-github-release
64+
65+
# Canary release for CI/CD
66+
pdk release --canary
67+
```
68+
69+
**Release Flow:**
70+
1. Select version type (patch/minor/major/prerelease)
71+
2. Choose NPM tag (latest/next/beta)
72+
3. Update workspace dependencies
73+
4. Publish packages to NPM
74+
5. Create git tag and push to remote
75+
6. Generate CHANGELOG.md
76+
7. Create GitHub Release
77+
78+
**Failed Release Recovery:**
79+
```bash
80+
pdk patch --version 1.0.0 --tag latest
81+
```
82+
83+
**Changelog Generation:**
84+
```bash
85+
# Standard changelog
86+
pdk changelog --version 1.0.0 --beautify --commit --git-push
87+
88+
# AI-powered changelog
89+
pdk changelog --version 1.0.0 --use-ai --provider openai --model gpt-4o
90+
```
91+
92+
**GitHub Release:**
93+
```bash
94+
pdk github-release --version 1.0.0
95+
pdk github-release --dry-run # Preview
96+
```
97+
98+
**Key Options:**
99+
- `--dry-run`: Preview without changes
100+
- `--run-in-band`: Publish packages in series
101+
- `--build`: Custom build script before release
102+
- `--ignore-scripts`: Skip npm scripts
103+
- `--auto-create-release-branch`: Auto-create release branch
104+
- `--filter-scopes`: Filter by scope (default: tars,agent,tarko,o-agent,tars-stack,browser,infra,mcp,all)
105+
- `--filter-types`: Filter by commit type (default: feat,fix)
106+
107+
## Configuration
108+
109+
**package.json Scripts:**
110+
```json
111+
{
112+
"scripts": {
113+
"dev": "pdk dev",
114+
"release": "pdk release --push-tag",
115+
"release:full": "pdk release --push-tag --create-github-release",
116+
"release:canary": "pdk release --canary",
117+
"github-release": "pdk github-release",
118+
"changelog": "pdk changelog",
119+
"patch": "pdk patch --version $(node -p \"require('./package.json').version\") --tag latest"
120+
}
121+
}
122+
```
123+
124+
**Workspace Setup:**
125+
- Uses `pnpm-workspace.yaml` for package discovery
126+
- Follows conventional commit standards
127+
- Auto-updates internal workspace dependencies
128+
129+
**CI/CD Integration:**
130+
```yaml
131+
# .github/workflows/release.yml
132+
name: Release
133+
on:
134+
push:
135+
tags:
136+
- 'v*'
137+
jobs:
138+
release:
139+
runs-on: ubuntu-latest
140+
steps:
141+
- uses: actions/checkout@v3
142+
- uses: actions/setup-node@v3
143+
with:
144+
node-version: '18'
145+
- run: npm install -g pnpm
146+
- run: pnpm install
147+
- run: pnpm run release:full
148+
env:
149+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
150+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
151+
```
152+
153+
**Best Practices:**
154+
- Always release from latest main branch
155+
- Ensure clean working directory
156+
- Run tests before release
157+
- Use `--dry-run` for testing
158+
- Canary format: `{version}-canary-{commitHash}-{timestamp}`
159+
- Auto-rollback on publish failure
160+
161+
## License
162+
163+
This project is licensed under the Apache License 2.0.

multimodal/tarko/pnpm-toolkit/package.json renamed to infra/pdk/package.json

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
2-
"name": "@tarko/pnpm-toolkit",
3-
"description": "PTK (pnpm toolkit), an pnpm workspace developement and publishing tool, designed for Agent TARS.",
4-
"version": "0.3.0",
2+
"name": "pnpm-dev-kit",
3+
"description": "PDK (pnpm dev kit), an efficient pnpm workspace development and publishing tool",
4+
"version": "0.0.4",
55
"main": "dist/index.js",
66
"module": "dist/index.mjs",
77
"types": "dist/index.d.ts",
@@ -14,15 +14,16 @@
1414
"bin"
1515
],
1616
"bin": {
17-
"ptk": "bin/cli.js"
17+
"pdk": "bin/cli.js"
1818
},
1919
"scripts": {
2020
"dev": "rslib build --watch",
2121
"build": "rslib build",
22+
"build:pdk": "rslib build",
2223
"prepublishOnly": "pnpm run build"
2324
},
2425
"dependencies": {
25-
"@tarko/model-provider": "workspace:*",
26+
"@tarko/model-provider": "0.3.0",
2627
"boxen": "4",
2728
"cac": "^6.5.10",
2829
"chalk": "2.4.1",
@@ -38,7 +39,7 @@
3839
"tiny-conventional-commits-parser": "^0.0.1"
3940
},
4041
"devDependencies": {
41-
"@rslib/core": "0.10.0",
42+
"@rslib/core": "0.15.1",
4243
"@types/fs-extra": "11.0.2",
4344
"@types/inquirer": "^8.2.5",
4445
"@types/js-yaml": "^4.0.5",
File renamed without changes.
Lines changed: 76 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@ import { logger } from './utils/logger';
1414
* Wraps a command execution with error handling
1515
*/
1616
// eslint-disable-next-line @typescript-eslint/ban-types
17-
async function wrapCommand(command: Function, options: Record<string, unknown>) {
17+
async function wrapCommand(
18+
// eslint-disable-next-line @typescript-eslint/ban-types
19+
command: Function,
20+
options: Record<string, unknown>,
21+
) {
1822
options.cwd = options.cwd || process.cwd();
1923

2024
try {
@@ -43,9 +47,13 @@ export function bootstrapCli() {
4347
cli
4448
.command('d', 'Quickly launch on-demand development build for monorepo')
4549
.alias('dev')
46-
.option('--exclude <packages>', 'Comma-separated list of packages to exclude', {
47-
default: '',
48-
})
50+
.option(
51+
'--exclude <packages>',
52+
'Comma-separated list of packages to exclude',
53+
{
54+
default: '',
55+
},
56+
)
4957
.option(
5058
'--packages, --pkg <packages>',
5159
'Comma-separated list of packages to start by default',
@@ -87,46 +95,70 @@ export function bootstrapCli() {
8795
.option('--run-in-band', 'Whether to publish package in series', {
8896
default: false,
8997
})
90-
.option('--ignore-scripts', 'Ignore npm scripts during release and patch process', {
91-
default: false,
92-
})
98+
.option(
99+
'--ignore-scripts',
100+
'Ignore npm scripts during release and patch process',
101+
{
102+
default: false,
103+
},
104+
)
93105
.option('--tag-prefix <prefix>', 'Prefix for git tags', {
94106
default: 'v',
95107
})
96-
.option('--canary', 'Skip version/tag selection and auto-generate canary version', {
97-
default: false,
98-
})
108+
.option(
109+
'--canary',
110+
'Skip version/tag selection and auto-generate canary version',
111+
{
112+
default: false,
113+
},
114+
)
99115
.option('--use-ai', 'Use AI to generate changelog', {
100116
default: false,
101117
})
102118
.option('--provider <provider>', 'LLM provider to use (default: openai)')
103119
.option('--model <model>', 'LLM model to use (default: gpt-4o)')
104120
.option('--apiKey, --api-key <apiKey>', 'Custom API key for LLM')
105121
.option('--baseURL, --base-url <baseURL>', 'Custom base URL for LLM')
106-
.option('--filter-scopes <scopes>', 'Comma-separated list of scopes to include in changelog', {
107-
default: 'tars,agent,tarko,o-agent,tars-stack,browser,infra,mcp,all',
108-
})
122+
.option(
123+
'--filter-scopes <scopes>',
124+
'Comma-separated list of scopes to include in changelog',
125+
{
126+
default: 'tars,agent,tarko,o-agent,tars-stack,browser,infra,mcp,all',
127+
},
128+
)
109129
.option(
110130
'--filter-types <types>',
111131
'Comma-separated list of commit types to include in changelog',
112132
{
113133
default: 'feat,fix',
114134
},
115135
)
116-
.option('--create-github-release', 'Create GitHub release after successful release', {
117-
default: false,
118-
})
119-
.option('--auto-create-release-branch', 'Automatically create release branch before release', {
120-
default: false,
121-
})
136+
.option(
137+
'--create-github-release',
138+
'Create GitHub release after successful release',
139+
{
140+
default: false,
141+
},
142+
)
143+
.option(
144+
'--auto-create-release-branch',
145+
'Automatically create release branch before release',
146+
{
147+
default: false,
148+
},
149+
)
122150
.alias('release')
123151
.action((opts) => {
124152
// Process filter options
125153
if (opts.filterScopes) {
126-
opts.filterScopes = opts.filterScopes.split(',').map((s: string) => s.trim());
154+
opts.filterScopes = opts.filterScopes
155+
.split(',')
156+
.map((s: string) => s.trim());
127157
}
128158
if (opts.filterTypes && opts.filterTypes.trim()) {
129-
opts.filterTypes = opts.filterTypes.split(',').map((s: string) => s.trim());
159+
opts.filterTypes = opts.filterTypes
160+
.split(',')
161+
.map((s: string) => s.trim());
130162
} else {
131163
opts.filterTypes = [];
132164
}
@@ -136,9 +168,13 @@ export function bootstrapCli() {
136168
// Patch command
137169
cli
138170
.command('p', 'Patch the failure of release process')
139-
.option('--patch-version <version>', 'Version (e.g. 1.0.0, 2.0.0-alpha.9)', {
140-
// There is no default value here, because the default is read from package.json
141-
})
171+
.option(
172+
'--patch-version <version>',
173+
'Version (e.g. 1.0.0, 2.0.0-alpha.9)',
174+
{
175+
// There is no default value here, because the default is read from package.json
176+
},
177+
)
142178
.option('--tag <tag>', 'Tag (e.g. latest, next, beta)')
143179
.option('--run-in-band', 'Whether to publish package in series', {
144180
default: false,
@@ -158,6 +194,9 @@ export function bootstrapCli() {
158194
// Changelog command
159195
cli
160196
.command('changelog', 'Create changelog')
197+
.option('--dry-run', 'Preview execution without making changes', {
198+
default: false,
199+
})
161200
.option('--changelog-version <version>', 'Version', {
162201
// There is no default value here, because the default is read from package.json
163202
})
@@ -186,9 +225,13 @@ export function bootstrapCli() {
186225
.option('--model <model>', 'LLM model to use (default: gpt-4o)')
187226
.option('--apiKey, --api-key <apiKey>', 'Custom API key for LLM')
188227
.option('--baseURL, --base-url <baseURL>', 'Custom base URL for LLM')
189-
.option('--filter-scopes <scopes>', 'Comma-separated list of scopes to include in changelog', {
190-
default: 'tars,agent,tarko,o-agent,tars-stack,browser,infra,mcp,all',
191-
})
228+
.option(
229+
'--filter-scopes <scopes>',
230+
'Comma-separated list of scopes to include in changelog',
231+
{
232+
default: 'tars,agent,tarko,o-agent,tars-stack,browser,infra,mcp,all',
233+
},
234+
)
192235
.option(
193236
'--filter-types <types>',
194237
'Comma-separated list of commit types to include in changelog',
@@ -203,10 +246,14 @@ export function bootstrapCli() {
203246
}
204247
// Process filter options
205248
if (opts.filterScopes) {
206-
opts.filterScopes = opts.filterScopes.split(',').map((s: string) => s.trim());
249+
opts.filterScopes = opts.filterScopes
250+
.split(',')
251+
.map((s: string) => s.trim());
207252
}
208253
if (opts.filterTypes && opts.filterTypes.trim()) {
209-
opts.filterTypes = opts.filterTypes.split(',').map((s: string) => s.trim());
254+
opts.filterTypes = opts.filterTypes
255+
.split(',')
256+
.map((s: string) => s.trim());
210257
} else {
211258
opts.filterTypes = [];
212259
}

0 commit comments

Comments
 (0)