@@ -277,6 +277,70 @@ async function buildViaGitHub(version) {
277277 }
278278}
279279
280+ async function getMainAction ( ) {
281+ log ( '\n🎯 Main Action' , 'bright' ) ;
282+ log ( 'What would you like to do?' , 'cyan' ) ;
283+ console . log ( ' 1) Create new release' ) ;
284+ console . log ( ' 2) Delete existing tag' ) ;
285+
286+ const choice = await question ( '\nSelect (1-2): ' ) ;
287+ return choice === '2' ? 'delete' : 'release' ;
288+ }
289+
290+ async function deleteTag ( ) {
291+ log ( '\n🗑️ Delete Tag' , 'bright' ) ;
292+
293+ // Show existing tags
294+ try {
295+ const tags = execCommand ( 'git tag -l' , true ) ;
296+ if ( tags ) {
297+ log ( '\n📋 Existing tags:' , 'cyan' ) ;
298+ tags . split ( '\n' ) . forEach ( tag => {
299+ if ( tag . trim ( ) ) {
300+ console . log ( ` ${ tag } ` ) ;
301+ }
302+ } ) ;
303+ } else {
304+ log ( '\n⚠️ No tags found in repository' , 'yellow' ) ;
305+ }
306+ } catch ( error ) {
307+ log ( '\n⚠️ Could not fetch tags' , 'yellow' ) ;
308+ }
309+
310+ const tagName = await question ( '\nEnter tag name to delete (e.g., v1.3.3): ' ) ;
311+
312+ if ( ! tagName ) {
313+ log ( '❌ No tag name provided' , 'red' ) ;
314+ return ;
315+ }
316+
317+ // Confirm deletion
318+ const confirm = await question ( `\n⚠️ Are you sure you want to delete tag '${ tagName } ' locally and remotely? (y/N): ` ) ;
319+
320+ if ( confirm . toLowerCase ( ) !== 'y' ) {
321+ log ( 'Aborted.' , 'yellow' ) ;
322+ return ;
323+ }
324+
325+ try {
326+ // Delete local tag
327+ log ( `\n🗑️ Deleting local tag '${ tagName } '...` , 'blue' ) ;
328+ execCommand ( `git tag -d ${ tagName } ` ) ;
329+ log ( `✅ Local tag '${ tagName } ' deleted` , 'green' ) ;
330+
331+ // Delete remote tag
332+ log ( `\n🗑️ Deleting remote tag '${ tagName } '...` , 'blue' ) ;
333+ execCommand ( `git push origin --delete ${ tagName } ` ) ;
334+ log ( `✅ Remote tag '${ tagName } ' deleted` , 'green' ) ;
335+
336+ log ( '\n✅ Tag deletion completed successfully!' , 'green' ) ;
337+
338+ } catch ( error ) {
339+ log ( `\n❌ Tag deletion failed: ${ error . message } ` , 'red' ) ;
340+ throw error ;
341+ }
342+ }
343+
280344async function main ( ) {
281345 log ( '🚀 KHM Tools Release Script' , 'bright' ) ;
282346 log ( '==========================\n' , 'bright' ) ;
@@ -287,6 +351,14 @@ async function main() {
287351 throw new Error ( 'package.json not found. Please run this script from the project root.' ) ;
288352 }
289353
354+ // Get main action
355+ const action = await getMainAction ( ) ;
356+
357+ if ( action === 'delete' ) {
358+ await deleteTag ( ) ;
359+ return ;
360+ }
361+
290362 // Check git status
291363 const branch = execCommand ( 'git branch --show-current' , true ) ;
292364 if ( branch !== 'main' ) {
0 commit comments