Skip to content

Commit cda4152

Browse files
committed
chore: auto-increment patch version [skip-version]
1 parent 86073f2 commit cda4152

4 files changed

Lines changed: 120 additions & 2 deletions

File tree

.githooks/commit-msg

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/bin/bash
2+
# Auto-increment patch version on every commit (unless [skip-version])
3+
# Only updates VERSION files + lpb.stack.env LPB_PI_REF
4+
# Does NOT touch package.json versions (kept at original fork versions)
5+
6+
COMMIT_MSG_FILE="$1"
7+
COMMIT_MSG=$(cat "$COMMIT_MSG_FILE")
8+
if echo "$COMMIT_MSG" | grep -q '\[skip-version\]'; then exit 0; fi
9+
10+
DEVSTACK_DIR="$(cd "$(dirname "$0")/.." && pwd)"
11+
[ ! -f "$DEVSTACK_DIR/VERSION" ] && exit 0
12+
13+
VERSION=$(cat "$DEVSTACK_DIR/VERSION" 2>/dev/null || echo "0.0.0-lpb")
14+
BASE=$(echo "$VERSION" | sed 's/^[0-9]*\.[0-9]*\.[0-9]*//')
15+
PATCH=$(echo "$VERSION" | sed 's/^[0-9]*\.[0-9]*\.\([0-9]*\).*/\1/')
16+
NEW_PATCH=$((PATCH + 1))
17+
NEW_VERSION="0.0.${NEW_PATCH}${BASE}"
18+
19+
echo "$NEW_VERSION" > "$DEVSTACK_DIR/VERSION"
20+
21+
# Update VERSION in all stack repos
22+
declare -a REPOS=(
23+
"$DEVSTACK_DIR/workspace/pi"
24+
"/home/lpb/.pi/agent/git/github.com/localpibox/lemonade-pi-plugin"
25+
"/home/lpb/workspace/localpibox/config"
26+
"/home/lpb/workspace/localpibox/lpb-memory"
27+
"/home/lpb/.pi/agent/git/github.com/localpibox/pi-subagents"
28+
)
29+
for repo in "${REPOS[@]}"; do
30+
[ -f "$repo/VERSION" ] && echo "$NEW_VERSION" > "$repo/VERSION"
31+
done
32+
33+
# Update lpb.stack.env
34+
[ -f "$DEVSTACK_DIR/lpb.stack.env" ] && sed -i "s/^LPB_PI_REF=.*/LPB_PI_REF=$NEW_VERSION/" "$DEVSTACK_DIR/lpb.stack.env"
35+
36+
exit 0
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
#!/bin/bash
2+
# commit-msg hook — Auto-increment patch version on every commit
3+
#
4+
# Reads VERSION from devstack, bumps patch, updates all 6 repos.
5+
# Skip versioning with: --no-verify or [skip-version] in commit message.
6+
#
7+
# Usage:
8+
# Hook installed automatically via `git config core.hooksPath hooks`
9+
# Place scripts in .git/hooks/ or use git config core.hooksPath
10+
11+
COMMIT_MSG_FILE="$1"
12+
COMMIT_MSG=$(cat "$COMMIT_MSG_FILE")
13+
14+
# Skip if commit message has [skip-version]
15+
if echo "$COMMIT_MSG" | grep -q '\[skip-version\]'; then
16+
exit 0
17+
fi
18+
19+
# Only run in devstack repo
20+
SCRIPT_DIR="$(cd "$(dirname "$0")/.." && pwd)"
21+
DEVSTACK_DIR="$(dirname "$SCRIPT_DIR")"
22+
if [ ! -f "$DEVSTACK_DIR/VERSION" ]; then
23+
exit 0
24+
fi
25+
26+
# Parse version
27+
VERSION=$(cat "$DEVSTACK_DIR/VERSION" 2>/dev/null || echo "0.0.0-lpb")
28+
BASE=$(echo "$VERSION" | sed 's/^[0-9]*\.[0-9]*\.[0-9]*//')
29+
PATCH=$(echo "$VERSION" | sed 's/^[0-9]*\.[0-9]*\.\([0-9]*\).*/\1/')
30+
NEW_PATCH=$((PATCH + 1))
31+
NEW_VERSION="0.0.${NEW_PATCH}${BASE}"
32+
33+
# Only bump if actually a patch version (0.0.x-lpb pattern)
34+
if ! echo "$NEW_VERSION" | grep -qE '^0\.0\.[0-9]+-lpb$'; then
35+
exit 0
36+
fi
37+
38+
# Skip if version hasn't changed
39+
if [ "$NEW_VERSION" = "$VERSION" ]; then
40+
exit 0
41+
fi
42+
43+
# Update VERSION in devstack
44+
echo "$NEW_VERSION" > "$DEVSTACK_DIR/VERSION"
45+
46+
# Update VERSION in all stack repos
47+
declare -a REPOS=(
48+
"$DEVSTACK_DIR/workspace/pi"
49+
"/home/lpb/.pi/agent/git/github.com/localpibox/lemonade-pi-plugin"
50+
"/home/lpb/workspace/localpibox/config"
51+
"/home/lpb/workspace/localpibox/lpb-memory"
52+
"/home/lpb/.pi/agent/git/github.com/localpibox/pi-subagents"
53+
)
54+
55+
for repo in "${REPOS[@]}"; do
56+
if [ -f "$repo/VERSION" ]; then
57+
echo "$NEW_VERSION" > "$repo/VERSION"
58+
fi
59+
done
60+
61+
# Update lpb.stack.env LPB_PI_REF
62+
if [ -f "$DEVSTACK_DIR/lpb.stack.env" ]; then
63+
sed -i "s/^LPB_PI_REF=.*/LPB_PI_REF=$NEW_VERSION/" "$DEVSTACK_DIR/lpb.stack.env"
64+
fi
65+
66+
# Update package.json in repos that have it
67+
for repo in "${REPOS[@]}"; do
68+
if [ -f "$repo/package.json" ]; then
69+
python3 -c "
70+
import json, sys
71+
path = '$repo/package.json'
72+
with open(path) as f:
73+
d = json.load(f)
74+
d['version'] = '$NEW_VERSION'
75+
with open(path, 'w') as f:
76+
json.dump(d, f, indent=2)
77+
f.write('\n')
78+
" 2>/dev/null || true
79+
fi
80+
done
81+
82+
exit 0

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.0.3-lpb
1+
0.0.4-lpb

lpb.stack.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
# Fork URL — cumulative patches on top of earendil-works/pi
1515
LPB_PI_FORK=https://github.com/localpibox/pi.git
1616
# Branch — which branch to build from (the lpb branch is the stable base)
17-
LPB_PI_REF=0.0.3-lpb
17+
LPB_PI_REF=0.0.4-lpb
1818
# Upstream — original repo (for reference / rebasing)
1919
LPB_PI_UPSTREAM=https://github.com/earendil-works/pi.git
2020

0 commit comments

Comments
 (0)