feat: add pre-checks to release-all script for safety

Add validation checks before releasing:
- Ensure we're on the main branch to prevent accidental releases from feature branches
- Verify npm authentication to prevent failed publish attempts

This prevents common release mistakes and improves release workflow reliability.
This commit is contained in:
weishu
2025-12-25 12:30:10 +08:00
parent e5f9d8cbe8
commit 4fb2a203c6
2 changed files with 24 additions and 6 deletions
+6 -6
View File
@@ -1,6 +1,6 @@
{
"name": "@twsxtd/hapi",
"version": "0.1.0",
"version": "0.1.1",
"description": "App for agentic coding - access coding agent anywhere",
"author": "Kirill Dubovitskiy & weishu",
"license": "MIT",
@@ -25,11 +25,11 @@
}
},
"optionalDependencies": {
"@twsxtd/hapi-darwin-arm64": "0.1.0",
"@twsxtd/hapi-darwin-x64": "0.1.0",
"@twsxtd/hapi-linux-arm64": "0.1.0",
"@twsxtd/hapi-linux-x64": "0.1.0",
"@twsxtd/hapi-win32-x64": "0.1.0"
"@twsxtd/hapi-darwin-arm64": "0.1.1",
"@twsxtd/hapi-darwin-x64": "0.1.1",
"@twsxtd/hapi-linux-arm64": "0.1.1",
"@twsxtd/hapi-linux-x64": "0.1.1",
"@twsxtd/hapi-win32-x64": "0.1.1"
},
"scripts": {
"typecheck": "tsc --noEmit",
+18
View File
@@ -45,6 +45,24 @@ async function main(): Promise<void> {
const flags = [dryRun && 'dry-run', publishNpm && 'publish-npm', skipBuild && 'skip-build'].filter(Boolean);
console.log(`\n🚀 Starting release v${version}${flags.length ? ` (${flags.join(', ')})` : ''}\n`);
// Pre-check: Ensure we're on main branch
console.log('🔍 Pre-checks...');
const currentBranch = execSync('git branch --show-current', { encoding: 'utf-8', cwd: repoRoot }).trim();
if (currentBranch !== 'main') {
console.error(`❌ Release must be run from main branch (current: ${currentBranch})`);
process.exit(1);
}
console.log(' ✓ On main branch');
// Pre-check: Ensure npm is logged in
try {
const npmUser = execSync('npm whoami', { encoding: 'utf-8' }).trim();
console.log(` ✓ Logged in to npm as: ${npmUser}`);
} catch {
console.error('❌ Not logged in to npm. Run `npm login` first.');
process.exit(1);
}
// Step 1: Update package.json version
console.log('📦 Step 1: Updating package.json version...');
const pkgPath = join(projectRoot, 'package.json');