#!/usr/bin/env bash # Pousse la branche courante vers git.abonnel.fr/cedricAbonnel/folio # Ne pousse JAMAIS directement sur main — passer par une PR. # Usage : ./scripts/push.sh "message de commit" set -euo pipefail SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ROOT="$SCRIPT_DIR/.." MSG="${1:-}" if [[ -z "$MSG" ]]; then echo "Usage: $0 \"message de commit\"" exit 1 fi cd "$ROOT" if [ ! -d .git ]; then git init -b main git remote add origin https://git.abonnel.fr/cedricAbonnel/folio.git echo "→ Dépôt git initialisé" fi BRANCH=$(git rev-parse --abbrev-ref HEAD) if [[ "$BRANCH" == "main" ]]; then echo "✗ Refus de pousser directement sur main." echo " Créer une branche feature : git checkout -b feat/nom" exit 1 fi # Extraire la version depuis CHANGELOG.md (première entrée ## [X.Y.Z]) FOLIO_VERSION=$(grep -m1 '^\#\# \[[0-9]' CHANGELOG.md | sed 's/.*\[\([^]]*\)\].*/\1/') if [[ -z "$FOLIO_VERSION" ]]; then echo "✗ Impossible d'extraire la version depuis CHANGELOG.md" exit 1 fi echo "$FOLIO_VERSION" > public/version.txt echo "→ Version : $FOLIO_VERSION" git add -A git diff --cached --quiet && echo "(rien à committer)" && exit 0 git commit -m "$MSG" git push origin "$BRANCH" echo "✓ Poussé vers folio (branche $BRANCH)" echo " → Ouvrir une PR sur https://git.abonnel.fr/cedricAbonnel/folio/pulls/new/$BRANCH"