diff --git a/B4A/_git_tag.ps1 b/B4A/_git_tag.ps1 new file mode 100644 index 0000000..2dac50a --- /dev/null +++ b/B4A/_git_tag.ps1 @@ -0,0 +1,45 @@ +param([string]$projectPath, [string]$projectName) + +$b4aFile = Join-Path $projectPath "$projectName.b4a" +if (-Not (Test-Path $b4aFile)) { return } + +# Extraer VersionName del código B4A [cite: 1495, 1502] +$versionLine = Get-Content $b4aFile | Select-String "#VersionName:" +$version = ($versionLine -split ":")[1].Trim() +$tagName = "v$version" + +Set-Location $projectPath +$oldCommit = git rev-parse HEAD + +# Abrir ventana de Commit de TortoiseGit [cite: 1226] +Write-Host "Esperando commit para version $version..." +$process = Start-Process "TortoiseGitProc.exe" -ArgumentList "/command:commit", "/path:`"$projectPath`"", "/logmsg:`"Version $version`"" -Wait -PassThru + +$newCommit = git rev-parse HEAD + +if ($oldCommit -ne $newCommit) { + # Verificar si el Tag ya existe en el servidor (GitHub) + $tagExistsRemote = git ls-remote --tags origin $tagName + + if ($tagExistsRemote) { + $confirm = Read-Host "El tag $tagName ya existe en GitHub. ¿Deseas SOBRESCRIBIRLO? (s/n)" + if ($confirm -ne "s") { + Write-Warning "Proceso abortado. Cambia la version en B4A y repite el proceso." + return + } + # Borrar local y remoto para permitir la actualizacion + git tag -d $tagName 2>$null + git push origin --delete $tagName 2>$null + } + + # Crear nuevo Tag local + git tag -a $tagName -m "Release version $version" + + # Subir cambios y el tag (usando -f solo para el tag si fuera necesario) + Write-Host "Subiendo cambios a GitHub..." + git push origin --follow-tags + + Write-Host "¡Completado! Version $version actualizada en GitHub." +} else { + Write-Warning "Commit cancelado. No se realizaron cambios." +} \ No newline at end of file