Skip to content

Commit 2a507b8

Browse files
committed
feat: add release script
1 parent 3370095 commit 2a507b8

File tree

4 files changed

+102
-5
lines changed

4 files changed

+102
-5
lines changed

β€Žmanifest-full.jsonβ€Ž

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"mcpb_version": "0.1",
3-
"version": "2.2.1",
2+
"manifest_version": "0.1",
3+
"version": "2.3.3",
44
"name": "postman-mcp-server-full",
55
"display_name": "Postman MCP Server (Full)",
66
"description": "A comprehensive MCP server with all available Postman API tools (106+ tools).",

β€Žmanifest-minimal.jsonβ€Ž

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"mcpb_version": "0.1",
3-
"version": "2.2.1",
2+
"manifest_version": "0.1",
3+
"version": "2.3.3",
44
"name": "postman-mcp-server-minimal",
55
"display_name": "Postman MCP Server (Minimal)",
66
"description": "A minimal MCP server with essential Postman API tools (37 tools).",

β€Žpackage.jsonβ€Ž

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@
1010
"prepack": "npm run build",
1111
"test": "vitest",
1212
"lint": "eslint",
13-
"lint:fix": "eslint --fix"
13+
"lint:fix": "eslint --fix",
14+
"preversion": "npm run build",
15+
"version": "git add dist/",
16+
"release": "npm version",
17+
"release-custom": "node scripts/release.js"
1418
},
1519
"bin": "dist/src/index.js",
1620
"files": [

β€Žscripts/release.jsβ€Ž

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
#!/usr/bin/env node
2+
3+
import { execSync } from 'child_process';
4+
import { readFileSync, writeFileSync } from 'fs';
5+
6+
const versionType = process.argv[2];
7+
if (!versionType) {
8+
console.error('Usage: npm run release-custom <major|minor|patch|version>');
9+
console.error('Examples:');
10+
console.error(' npm run release-custom patch');
11+
console.error(' npm run release-custom minor');
12+
console.error(' npm run release-custom 2.3.3');
13+
process.exit(1);
14+
}
15+
16+
function incrementVersion(currentVersion, type) {
17+
// Clean the version string and split
18+
const cleanVersion = currentVersion.replace(/^v/, ''); // Remove 'v' prefix if present
19+
const parts = cleanVersion.split('.');
20+
21+
if (parts.length !== 3) {
22+
throw new Error(`Invalid version format: ${currentVersion}. Expected format: x.y.z`);
23+
}
24+
25+
const [major, minor, patch] = parts.map(part => {
26+
const num = parseInt(part, 10);
27+
if (isNaN(num)) {
28+
throw new Error(`Invalid version part: ${part} in version ${currentVersion}`);
29+
}
30+
return num;
31+
});
32+
33+
console.log(`πŸ” Current version parts: major=${major}, minor=${minor}, patch=${patch}`);
34+
35+
switch (type) {
36+
case 'major':
37+
return `${major + 1}.0.0`;
38+
case 'minor':
39+
return `${major}.${minor + 1}.0`;
40+
case 'patch':
41+
return `${major}.${minor}.${patch + 1}`;
42+
default:
43+
// Validate specific version format
44+
if (!/^\d+\.\d+\.\d+$/.test(type)) {
45+
throw new Error(`Invalid version format: ${type}. Use 'major', 'minor', 'patch', or a version like '1.2.3'`);
46+
}
47+
return type;
48+
}
49+
}
50+
51+
try {
52+
// Read current version
53+
const pkg = JSON.parse(readFileSync('package.json', 'utf8'));
54+
const currentVersion = pkg.version;
55+
const newVersion = incrementVersion(currentVersion, versionType);
56+
57+
console.log(`πŸ“¦ Updating version from ${currentVersion} to ${newVersion}`);
58+
59+
// Update package.json version
60+
pkg.version = newVersion;
61+
writeFileSync('package.json', JSON.stringify(pkg, null, 2) + '\n');
62+
63+
// Update package-lock.json version
64+
console.log('πŸ”’ Updating package-lock.json...');
65+
execSync('npm install --package-lock-only', { stdio: 'inherit' });
66+
67+
// Build project
68+
console.log('πŸ”¨ Building project...');
69+
execSync('npm run build', { stdio: 'inherit' });
70+
71+
// Update manifest versions
72+
console.log('πŸ“ Updating manifest files...');
73+
const updateManifest = (file) => {
74+
const manifest = JSON.parse(readFileSync(file, 'utf8'));
75+
manifest.version = newVersion;
76+
writeFileSync(file, JSON.stringify(manifest, null, 2) + '\n');
77+
};
78+
79+
updateManifest('manifest-full.json');
80+
updateManifest('manifest-minimal.json');
81+
82+
// Commit and tag
83+
console.log('πŸ“€ Committing and tagging...');
84+
execSync('git add .', { stdio: 'inherit' });
85+
execSync(`git commit -m "chore: v${newVersion}"`, { stdio: 'inherit' });
86+
execSync(`git tag v${newVersion}`, { stdio: 'inherit' });
87+
88+
console.log(`βœ… Released version ${newVersion}`);
89+
console.log(`πŸš€ Push with: git push origin main --tags`);
90+
} catch (error) {
91+
console.error('❌ Release failed:', error.message);
92+
process.exit(1);
93+
}

0 commit comments

Comments
Β (0)