diff --git a/build.sh b/build.sh index 3f092f8..67dcc16 100755 --- a/build.sh +++ b/build.sh @@ -1,11 +1,20 @@ #!/usr/bin/env bash -# Compila gitswarm a un binario standalone con Nuitka. +# Compila gitswarm a un binario standalone con Nuitka y empaqueta un tar.gz de release. # Requisitos del sistema: python3-dev, gcc, patchelf (ver README). set -euo pipefail HERE="$(cd "$(dirname "$0")" && pwd)" cd "$HERE" +VERSION="$(grep -oP '__version__\s*=\s*"\K[^"]+' gitswarm.py)" +if [ -z "$VERSION" ]; then + echo "[build] no se pudo leer __version__ de gitswarm.py" >&2 + exit 1 +fi +ARCH="$(uname -m)" +OS="$(uname -s | tr '[:upper:]' '[:lower:]')" +RELEASE_NAME="gitswarm-v${VERSION}-${OS}-${ARCH}" + if [ ! -d .venv ]; then echo "[build] creando venv…" python3 -m venv .venv @@ -18,6 +27,7 @@ if ! .venv/bin/python -c "import nuitka" 2>/dev/null; then .venv/bin/pip install --quiet nuitka fi +echo "[build] versión: v${VERSION}" echo "[build] limpiando artefactos previos…" rm -rf dist build gitswarm.build gitswarm.dist gitswarm.onefile-build @@ -32,6 +42,9 @@ echo "[build] compilando (esto puede tardar 1-2 min)…" --include-package=rich \ gitswarm.py +echo "[build] empaquetando release ${RELEASE_NAME}.tar.gz…" +tar -czf "dist/${RELEASE_NAME}.tar.gz" -C dist gitswarm + echo "[build] hecho:" -ls -lh dist/gitswarm +ls -lh "dist/gitswarm" "dist/${RELEASE_NAME}.tar.gz" echo "[build] instalar con: cp dist/gitswarm ~/.local/bin/" diff --git a/gitswarm b/gitswarm deleted file mode 100755 index 4f8a8a8..0000000 --- a/gitswarm +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env bash -# Wrapper que ejecuta gitswarm.py dentro del venv local. -HERE="$(cd "$(dirname "$0")" && pwd)" -exec "$HERE/.venv/bin/python" "$HERE/gitswarm.py" "$@" diff --git a/gitswarm.py b/gitswarm.py index af84554..868d489 100644 --- a/gitswarm.py +++ b/gitswarm.py @@ -16,6 +16,8 @@ from rich.prompt import Prompt from rich.table import Table from rich.text import Text +__version__ = "1.0.0" + console = Console() @@ -211,13 +213,16 @@ HELP = """[bold]Comandos:[/bold] [cyan]refresh[/cyan] / [cyan]r[/cyan] Re-escanea haciendo git fetch [cyan]update [/cyan] git pull --ff-only en ese repo (acepta nº, nombre o trozo) [cyan]update all[/cyan] Actualiza todos los que estén behind + [cyan]version[/cyan] / [cyan]v[/cyan] Muestra la versión [cyan]help[/cyan] / [cyan]?[/cyan] Esta ayuda [cyan]quit[/cyan] / [cyan]q[/cyan] Salir (también Ctrl-D / Ctrl-C) """ def repl(base: Path) -> None: - console.print(f"[dim]gitswarm — escaneando[/dim] [bold]{base}[/bold]") + console.print( + f"[dim]gitswarm v{__version__} — escaneando[/dim] [bold]{base}[/bold]" + ) repos = scan(base, fetch=True) if not repos: console.print(f"[yellow]No se han encontrado repos git en {base}[/yellow]") @@ -245,6 +250,8 @@ def repl(base: Path) -> None: console.print(HELP) elif cmd in ("list", "ls"): console.print(render_table(repos)) + elif cmd in ("version", "v"): + console.print(f"gitswarm v{__version__}") elif cmd in ("refresh", "r"): repos = scan(base, fetch=True) console.print(render_table(repos)) @@ -262,6 +269,12 @@ def main() -> int: prog="gitswarm", description="Lista y actualiza repos git de primer nivel en una carpeta.", ) + parser.add_argument( + "-v", + "--version", + action="version", + version=f"gitswarm v{__version__}", + ) parser.add_argument("path", type=Path, help="Carpeta a escanear") args = parser.parse_args() if not args.path.is_dir(): diff --git a/requirements.txt b/requirements.txt index 51f97ae..91a1b78 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1,2 @@ rich>=13.0 +zstandard>=0.22