Commit f0aeb8e3 authored by Anthony Gautreau's avatar Anthony Gautreau
Browse files

Mise à jour du realease-api.sh

parent 19c8c24d
Loading
Loading
Loading
Loading
+63 −9
Changes for release-api.sh: 63 added lines, 9 removed lines.
Original line number Diff line number Diff line
#!/bin/bash
# release-api.sh

VERSION="$1"
BUMP_TYPE="${1:-patch}" # patch | minor | major | default patch

if [ -z "$VERSION" ]; then
  echo "Usage: ./release-api.sh v1.2.3"
if [ -z "$BUMP_TYPE" ]; then
  echo "Usage: ./release-api.sh patch| minor | major"
  exit 1
fi

echo "➡️  Génération split de /api pour version $VERSION..."
if ! command -v npm >/dev/null 2>&1; then
  echo "npm introuvable"; exit 1
fi

if ! command -v git >/dev/null 2>&1; then
  echo "git introuvable"; exit 1
fi

if [ ! -f frontend/package.json ]; then
  echo "Aucun package.json trouvé dans le dossier courant"; exit 1
fi

# Working tree clean ?
#if ! git diff --quiet || ! git diff --cached --quiet; then
#  echo "Votre working tree contient des changements non commités."
#  echo "   Committez ou stash avant de lancer la release."
#  exit 1
#fi

# Récupérer les dernières versions
git fetch --tags origin

cd frontend || exit 1

# Construire la commande npm version
NPM_VERSION_CMD=(npm version "$BUMP_TYPE" -m "chore(release): v%s")

echo "Bump version avec: ${NPM_VERSION_CMD[*]}"
NEW_VERSION=$("${NPM_VERSION_CMD[@]}" | tr -d 'v')

echo "✅ Nouvelle version: $NEW_VERSION"
echo "✅ Nouveau tag: $TAG"

git add package.json
git add package-lock.json

cd ..

echo "$NEW_VERSION" > api/.version
git add api/.version
git commit -m "Release: mise à jour version API $NEW_VERSION"

git push origin master

echo "Suppression éventuelle de la branche split-api locale..."
git branch -D split-api 2>/dev/null

echo "Génération split de /api pour version $NEW_VERSION..."
git subtree split --prefix=api -b split-api

echo "🏷️  Création du tag $VERSION sur split-api..."
git tag -f "$VERSION" split-api
echo "Push de split-api vers origin..."
git push origin split-api --force

echo "Création du tag $NEW_VERSION sur split-api..."
git tag -a "$NEW_VERSION" split-api
message=$(git tag -n --format='%(contents)' "$NEW_VERSION")

git push --tags origin split-api

echo "📤 Push du tag $VERSION vers origin..."
git push origin "$VERSION" --force
echo "Push du tag $NEW_VERSION vers origin..."
git tag -a -m "$message" m-"$NEW_VERSION" master
git push --tags origin master

echo "✅ Release $VERSION terminée."
echo "Release $NEW_VERSION terminée."