Files
Inventory/scripts/release.sh
Matthieu 73b2cf300d
All checks were successful
Build & Push Docker Image / build (push) Successful in 1m4s
refactor : rename Inventory_frontend to frontend everywhere
Update Dockerfile, nginx, .dockerignore, makefile, CI workflow,
CLAUDE.md, README, release script to use frontend/ instead of
Inventory_frontend/. Remove submodule references from CI and
release script.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-01 14:19:20 +02:00

148 lines
3.9 KiB
Bash
Executable File

#!/bin/bash
set -e
# Couleurs pour l'affichage
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Répertoire racine du projet
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
VERSION_FILE="$PROJECT_ROOT/VERSION"
API_PLATFORM_FILE="$PROJECT_ROOT/config/packages/api_platform.yaml"
# Lire la version actuelle
current_version=$(cat "$VERSION_FILE" | tr -d '\n')
# Fonction pour afficher l'aide
show_help() {
echo -e "${BLUE}Usage:${NC} $0 [version|bump_type]"
echo ""
echo "Arguments:"
echo " version Version spécifique (ex: 1.2.3)"
echo " bump_type Type de bump: major, minor, patch"
echo ""
echo "Exemples:"
echo " $0 1.0.0 # Définit la version à 1.0.0"
echo " $0 patch # 1.0.0 -> 1.0.1"
echo " $0 minor # 1.0.0 -> 1.1.0"
echo " $0 major # 1.0.0 -> 2.0.0"
echo ""
echo -e "Version actuelle: ${GREEN}$current_version${NC}"
}
# Fonction pour bumper la version
bump_version() {
local version=$1
local bump_type=$2
IFS='.' read -r major minor patch <<< "$version"
case $bump_type in
major)
major=$((major + 1))
minor=0
patch=0
;;
minor)
minor=$((minor + 1))
patch=0
;;
patch)
patch=$((patch + 1))
;;
esac
echo "$major.$minor.$patch"
}
# Vérifier les arguments
if [ $# -eq 0 ]; then
show_help
exit 0
fi
arg=$1
# Déterminer la nouvelle version
case $arg in
major|minor|patch)
new_version=$(bump_version "$current_version" "$arg")
;;
-h|--help|help)
show_help
exit 0
;;
*)
# Vérifier le format de version (semver basique)
if [[ $arg =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
new_version=$arg
else
echo -e "${RED}Erreur:${NC} Format de version invalide: $arg"
echo "Utilisez le format X.Y.Z (ex: 1.2.3) ou major/minor/patch"
exit 1
fi
;;
esac
echo -e "${BLUE}Release v$new_version${NC}"
echo "================================"
echo -e "Version actuelle: ${YELLOW}$current_version${NC}"
echo -e "Nouvelle version: ${GREEN}$new_version${NC}"
echo ""
# Vérifier qu'on n'est pas sur une version identique
if [ "$current_version" = "$new_version" ]; then
echo -e "${YELLOW}La version est déjà $new_version${NC}"
exit 0
fi
# Demander confirmation
read -p "Continuer ? (y/N) " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
echo "Annulé."
exit 0
fi
cd "$PROJECT_ROOT"
# ===========================================
# ÉTAPE 1 : Mettre à jour VERSION
# ===========================================
echo -e "${BLUE}[1/4]${NC} Mise à jour du fichier VERSION..."
echo "$new_version" > "$VERSION_FILE"
# ===========================================
# ÉTAPE 2 : Mettre à jour api_platform.yaml
# ===========================================
echo -e "${BLUE}[2/4]${NC} Mise à jour de api_platform.yaml..."
sed -i "s/version: .*/version: $new_version/" "$API_PLATFORM_FILE"
# ===========================================
# ÉTAPE 3 : Commit
# ===========================================
echo -e "${BLUE}[3/4]${NC} Création du commit..."
git add "$VERSION_FILE" "$API_PLATFORM_FILE"
git commit -m "chore(release) : v$new_version"
# ===========================================
# ÉTAPE 4 : Tag
# ===========================================
echo -e "${BLUE}[4/4]${NC} Création du tag v$new_version..."
git tag -a "v$new_version" -m "Release v$new_version"
echo ""
echo -e "${GREEN}✓ Release v$new_version préparée avec succès !${NC}"
echo ""
echo "================================"
echo -e "${YELLOW}Prochaines étapes :${NC}"
echo ""
echo "Pousser le projet :"
echo -e " ${BLUE}git push && git push --tags${NC}"
echo ""
echo "================================"