2026-01-11 20:24:47 +09:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
set -euo pipefail
|
|
|
|
|
|
|
|
|
|
PUBSPEC="pubspec.yaml"
|
|
|
|
|
if [[ ! -f "$PUBSPEC" ]]; then
|
|
|
|
|
echo "No $PUBSPEC found in $(pwd); skipping version bump"
|
|
|
|
|
exit 0
|
|
|
|
|
fi
|
|
|
|
|
|
2026-01-11 20:28:24 +09:00
|
|
|
# Use a short Python helper for robust YAML-safe replacement
|
|
|
|
|
python3 - <<'PY'
|
|
|
|
|
import re
|
|
|
|
|
from pathlib import Path
|
|
|
|
|
p = Path('pubspec.yaml')
|
|
|
|
|
s = p.read_text()
|
|
|
|
|
# find first version: line
|
|
|
|
|
m = re.search(r"^([ \t]*version:\s*)([0-9]+)\.([0-9]+)\.([0-9]+)(\+[0-9]+)?\s*$", s, re.M)
|
|
|
|
|
if not m:
|
|
|
|
|
print('No parsable version line found; skipping')
|
|
|
|
|
raise SystemExit(0)
|
|
|
|
|
prefix = m.group(1)
|
|
|
|
|
major = int(m.group(2)); minor = int(m.group(3)); patch = int(m.group(4)); build = m.group(5) or ''
|
|
|
|
|
new_patch = patch + 1
|
|
|
|
|
newver = f"{major}.{minor}.{new_patch}{build}"
|
|
|
|
|
new_line = prefix + newver
|
|
|
|
|
s2 = s[:m.start()] + new_line + s[m.end():]
|
|
|
|
|
p.write_text(s2)
|
|
|
|
|
print('pubspec version bumped to', newver)
|
|
|
|
|
PY
|
2026-01-11 20:24:47 +09:00
|
|
|
|
|
|
|
|
# Stage the change so it is included in the commit
|
|
|
|
|
if git rev-parse --is-inside-work-tree >/dev/null 2>&1; then
|
|
|
|
|
git add "$PUBSPEC" || true
|
|
|
|
|
fi
|
|
|
|
|
|
2026-01-11 20:28:24 +09:00
|
|
|
exit 0
|