From 4fb2a203c65f8ca85f59cc9dfe5502f0edcb4aae Mon Sep 17 00:00:00 2001 From: weishu Date: Thu, 25 Dec 2025 12:30:10 +0800 Subject: [PATCH] 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. --- cli/package.json | 12 ++++++------ cli/scripts/release-all.ts | 18 ++++++++++++++++++ 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/cli/package.json b/cli/package.json index 12d2ae53..26f01cf3 100644 --- a/cli/package.json +++ b/cli/package.json @@ -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", diff --git a/cli/scripts/release-all.ts b/cli/scripts/release-all.ts index a63f98d9..81eabb98 100644 --- a/cli/scripts/release-all.ts +++ b/cli/scripts/release-all.ts @@ -45,6 +45,24 @@ async function main(): Promise { 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');