Skip to content

Commit 9aa1eed

Browse files
authored
feat: modify release script to update mcpb versions in server.json (#71)
* feat: modifying github action to publish to npm registry * feat: modifying release script to update mcpb packages in server.json
1 parent 7c94e18 commit 9aa1eed

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

scripts/release.js

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import { execSync } from 'child_process';
44
import { readFileSync, writeFileSync } from 'fs';
5+
import { createHash } from 'crypto';
56

67
const versionType = process.argv[2];
78
if (!versionType) {
@@ -13,6 +14,18 @@ if (!versionType) {
1314
process.exit(1);
1415
}
1516

17+
function calculateSHA256(filePath) {
18+
try {
19+
const fileBuffer = readFileSync(filePath);
20+
const hashSum = createHash('sha256');
21+
hashSum.update(fileBuffer);
22+
return hashSum.digest('hex');
23+
} catch (error) {
24+
console.warn(`⚠️ Could not calculate SHA256 for ${filePath}: ${error.message}`);
25+
return null;
26+
}
27+
}
28+
1629
function incrementVersion(currentVersion, type) {
1730
// Clean the version string and split
1831
const cleanVersion = currentVersion.replace(/^v/, ''); // Remove 'v' prefix if present
@@ -83,12 +96,39 @@ try {
8396
console.log('📝 Updating server.json...');
8497
const serverJson = JSON.parse(readFileSync('server.json', 'utf8'));
8598
serverJson.version = newVersion;
99+
86100
// Also update the version in the npm package entry
87101
if (serverJson.packages && Array.isArray(serverJson.packages)) {
88102
const npmPackage = serverJson.packages.find(pkg => pkg.registryType === 'npm');
89103
if (npmPackage) {
90104
npmPackage.version = newVersion;
91105
}
106+
107+
// Update mcpb packages with new identifiers and SHA256 hashes
108+
console.log('🔐 Calculating SHA256 hashes for mcpb packages...');
109+
const mcpbPackages = serverJson.packages.filter(pkg => pkg.registryType === 'mcpb');
110+
111+
const mcpbFiles = [
112+
{ name: 'postman-mcp-server-minimal.mcpb', path: 'postman-mcp-server-minimal.mcpb' },
113+
{ name: 'postman-mcp-server-full.mcpb', path: 'postman-mcp-server-full.mcpb' }
114+
];
115+
116+
mcpbFiles.forEach(file => {
117+
const mcpbPackage = mcpbPackages.find(pkg => pkg.identifier && pkg.identifier.includes(file.name));
118+
if (mcpbPackage) {
119+
// Update identifier URL with new version
120+
mcpbPackage.identifier = `https://github.com/postmanlabs/postman-mcp-server/releases/download/v${newVersion}/${file.name}`;
121+
122+
// Calculate and update SHA256 hash
123+
const sha256 = calculateSHA256(file.path);
124+
if (sha256) {
125+
mcpbPackage.fileSha256 = sha256;
126+
console.log(` ✓ ${file.name}: ${sha256}`);
127+
} else {
128+
console.warn(` ⚠️ Could not calculate SHA256 for ${file.name}`);
129+
}
130+
}
131+
});
92132
}
93133
writeFileSync('server.json', JSON.stringify(serverJson, null, 2) + '\n');
94134

0 commit comments

Comments
 (0)