chore(package): add auto-version script
This commit is contained in:
32
.husky/post-commit
Executable file
32
.husky/post-commit
Executable file
@@ -0,0 +1,32 @@
|
||||
#!/bin/sh
|
||||
# Auto-version hook: incrémente la version après certains commits
|
||||
|
||||
# Récupérer le dernier message de commit
|
||||
commit_msg=$(git log -1 --pretty=%B)
|
||||
|
||||
# Ignorer si le commit contient [skip version] ou si c'est un commit de version
|
||||
if echo "$commit_msg" | grep -qE "\[skip version\]|chore: bump version"; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Vérifier si le commit devrait déclencher une mise à jour de version
|
||||
# Types pris en charge:
|
||||
# - feat: → minor bump
|
||||
# - fix:, perf:, security:, patch:, refactor: → patch bump
|
||||
# - feat!:, refactor!:, etc. (avec !) → major bump
|
||||
# - breaking change ou BREAKING CHANGE → major bump
|
||||
# Ignorés: chore:, docs:, style:, test:, ci:, build:
|
||||
if echo "$commit_msg" | grep -qiE "^feat:|^fix:|^perf:|^security:|^patch:|^refactor:|^[a-z]+!:|breaking change"; then
|
||||
# Lancer le script en mode hook (silent + ajout auto au staging)
|
||||
pnpm tsx scripts/auto-version.ts --silent --hook
|
||||
|
||||
# Vérifier si package.json a changé
|
||||
if ! git diff --quiet package.json; then
|
||||
echo ""
|
||||
echo "📦 Version mise à jour automatiquement"
|
||||
echo "💡 Pour commit: git add package.json && git commit -m 'chore: bump version'"
|
||||
fi
|
||||
fi
|
||||
|
||||
exit 0
|
||||
|
||||
Reference in New Issue
Block a user