mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2026-03-23 07:37:24 +01:00
feat: implement version bumping script and pre-push hook
This commit is contained in:
parent
a66b60b5a7
commit
1f81dd2395
5 changed files with 285 additions and 3 deletions
29
scripts/pre-push
Executable file
29
scripts/pre-push
Executable file
|
|
@ -0,0 +1,29 @@
|
|||
#!/usr/bin/env sh
|
||||
# Git pre-push hook — automatically bumps the version before pushing.
|
||||
# Installed by: npm run prepare (scripts/install-hooks.js)
|
||||
#
|
||||
# Prompts for patch / minor / major (default: patch), updates:
|
||||
# - public/versioning.js
|
||||
# - package.json
|
||||
# - src/index.html (cache-busting ?v= hashes for changed modules)
|
||||
# then commits those changes so they are included in the push.
|
||||
|
||||
set -e
|
||||
|
||||
REPO_ROOT="$(git rev-parse --show-toplevel)"
|
||||
|
||||
echo ""
|
||||
node "$REPO_ROOT/scripts/bump-version.js"
|
||||
|
||||
# Stage files that may have been modified by the bump
|
||||
git add \
|
||||
"$REPO_ROOT/public/versioning.js" \
|
||||
"$REPO_ROOT/package.json" \
|
||||
"$REPO_ROOT/src/index.html" 2>/dev/null || true
|
||||
|
||||
# Only commit if there are staged changes from the bump
|
||||
if ! git diff --cached --quiet; then
|
||||
NEW_VERSION=$(node -e "const f=require('fs');const m=f.readFileSync('$REPO_ROOT/public/versioning.js','utf8').match(/const VERSION = \"([\d.]+)\"/);console.log(m[1])")
|
||||
git commit -m "chore: bump version to $NEW_VERSION"
|
||||
echo "[pre-push] Committed version bump → $NEW_VERSION"
|
||||
fi
|
||||
Loading…
Add table
Add a link
Reference in a new issue