🔨 [devops] Scripts para la publicación de crates

This commit is contained in:
Manuel Cillero 2025-08-05 18:53:01 +02:00
parent b4cbfc4775
commit 54cc741c1d
4 changed files with 261 additions and 0 deletions

48
tools/release.sh Executable file
View file

@ -0,0 +1,48 @@
#!/bin/bash
set -euo pipefail
# ------------------------------------------------------------------------------
# Script para publicar un crate individual del workspace con cargo-release.
# Uso:
# ./tools/release.sh <crate> [patch|minor|major] [--execute]
# Ejemplos:
# ./tools/release.sh pagetop-macros patch # Dry run (por defecto)
# ./tools/release.sh pagetop minor --execute # Publicación real
# ------------------------------------------------------------------------------
# Configuración
CRATE="${1:-}"
LEVEL="${2:-patch}"
EXECUTE="${3:-}"
CONFIG=".cargo/release.toml"
# Comprobaciones
if [[ -z "$CRATE" ]]; then
echo "Usage: $0 <crate> [patch|minor|major] [--execute]"
exit 1
fi
if [[ ! "$LEVEL" =~ ^(patch|minor|major)$ ]]; then
echo "Error: invalid level '$LEVEL'. Use: patch, minor, or major"
exit 1
fi
# Dependencias
command -v cargo-release >/dev/null || {
echo "Error: cargo-release is not installed. Use: cargo install cargo-release"
exit 1
}
# Cambia al directorio del espacio
cd "$(dirname "$0")/.." || exit 1
# ------------------------------------------------------------------------------
# DRY-RUN (por defecto) o ejecución real con --execute
# ------------------------------------------------------------------------------
if [[ "$EXECUTE" != "--execute" ]]; then
echo "Running dry-run (default mode). Add --execute to publish"
CARGO_RELEASE_CONFIG="$CONFIG" cargo release --package "$CRATE" "$LEVEL" --dry-run
else
echo "Releasing $CRATE ($LEVEL)…"
CARGO_RELEASE_CONFIG="$CONFIG" cargo release --package "$CRATE" "$LEVEL" --execute
echo "Release completed."
fi