refactor: add simple mode to releases
This commit is contained in:
@@ -8,58 +8,51 @@ import { execSync } from 'child_process';
|
|||||||
const packageJson = JSON.parse(fs.readFileSync('./package.json', 'utf8'));
|
const packageJson = JSON.parse(fs.readFileSync('./package.json', 'utf8'));
|
||||||
const version = packageJson.version;
|
const version = packageJson.version;
|
||||||
|
|
||||||
console.log(`📦 Building dist folder for version ${version}...`);
|
|
||||||
|
|
||||||
// Run the build command
|
|
||||||
try {
|
|
||||||
execSync('npm run build', { stdio: 'inherit' });
|
|
||||||
console.log('✅ Build completed successfully');
|
|
||||||
} catch (error) {
|
|
||||||
console.error('❌ Build failed:', error.message);
|
|
||||||
process.exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Package the dist folder into a zip file
|
|
||||||
import { createWriteStream, existsSync } from 'fs';
|
import { createWriteStream, existsSync } from 'fs';
|
||||||
import { pipeline } from 'stream';
|
|
||||||
import { promisify } from 'util';
|
|
||||||
import archiver from 'archiver';
|
import archiver from 'archiver';
|
||||||
|
|
||||||
const distDir = path.resolve('./dist');
|
function buildAndZip(label, envVars, zipName) {
|
||||||
const zipPath = path.resolve(`./dist-${version}.zip`);
|
console.log(`📦 Building ${label} dist for version ${version}...`);
|
||||||
|
|
||||||
// Check if dist directory exists
|
try {
|
||||||
if (!existsSync(distDir)) {
|
execSync(`${envVars} npm run build`, { stdio: 'inherit', shell: true });
|
||||||
console.error('❌ dist directory does not exist. Please run build first.');
|
console.log(`✅ ${label} build completed successfully`);
|
||||||
|
} catch (error) {
|
||||||
|
console.error(`❌ ${label} build failed:`, error.message);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a write stream for the zip file
|
const distDir = path.resolve('./dist');
|
||||||
|
const zipPath = path.resolve(zipName);
|
||||||
|
|
||||||
|
if (!existsSync(distDir)) {
|
||||||
|
console.error('❌ dist directory does not exist.');
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
const output = createWriteStream(zipPath);
|
const output = createWriteStream(zipPath);
|
||||||
const archive = archiver('zip', {
|
const archive = archiver('zip', { zlib: { level: 9 } });
|
||||||
zlib: { level: 9 } // Maximum compression
|
|
||||||
});
|
|
||||||
|
|
||||||
// Event listener for when the archive is finished
|
|
||||||
output.on('close', () => {
|
output.on('close', () => {
|
||||||
console.log(`✅ Successfully created ${zipPath}. Total bytes: ${archive.pointer()}`);
|
console.log(`✅ Created ${zipPath} (${archive.pointer()} bytes)`);
|
||||||
|
resolve();
|
||||||
});
|
});
|
||||||
|
|
||||||
// Event listener for errors
|
|
||||||
archive.on('error', (err) => {
|
archive.on('error', (err) => {
|
||||||
console.error('❌ Error creating zip:', err);
|
console.error('❌ Error creating zip:', err);
|
||||||
process.exit(1);
|
reject(err);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Pipe the archive to the file
|
|
||||||
archive.pipe(output);
|
archive.pipe(output);
|
||||||
|
|
||||||
// Append the dist directory to the archive
|
|
||||||
archive.directory(distDir, false);
|
archive.directory(distDir, false);
|
||||||
|
|
||||||
// Finalize the archive
|
|
||||||
archive.finalize();
|
archive.finalize();
|
||||||
|
|
||||||
output.on('close', () => {
|
|
||||||
console.log(`✅ Successfully created ${zipPath}. Total bytes: ${archive.pointer()}`);
|
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
await buildAndZip('Full mode', '', `dist-${version}.zip`);
|
||||||
|
await buildAndZip(
|
||||||
|
'Simple mode',
|
||||||
|
'SIMPLE_MODE=true',
|
||||||
|
`dist-simple-${version}.zip`
|
||||||
|
);
|
||||||
|
|||||||
@@ -98,12 +98,10 @@ function main() {
|
|||||||
console.log(`🎉 Release v${newVersion} complete!`);
|
console.log(`🎉 Release v${newVersion} complete!`);
|
||||||
console.log(`📦 Docker image: bentopdfteam/bentopdf:${newVersion}`);
|
console.log(`📦 Docker image: bentopdfteam/bentopdf:${newVersion}`);
|
||||||
console.log(`📦 Distribution: dist-${newVersion}.zip`);
|
console.log(`📦 Distribution: dist-${newVersion}.zip`);
|
||||||
|
console.log(`📦 Distribution (simple): dist-simple-${newVersion}.zip`);
|
||||||
console.log(
|
console.log(
|
||||||
`🏷️ GitHub release: https://github.com/alam00000/bentopdf/releases/tag/${tagName}`
|
`🏷️ GitHub release: https://github.com/alam00000/bentopdf/releases/tag/${tagName}`
|
||||||
);
|
);
|
||||||
console.log(
|
|
||||||
`💡 Download dist-${newVersion}.zip from the release page for self-hosting.`
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
main();
|
main();
|
||||||
|
|||||||
Reference in New Issue
Block a user