Files
yommi_ff/scripts/bump_patch_version.sh
2026-01-11 20:28:24 +09:00

36 lines
1003 B
Bash
Executable File

#!/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
# 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
# 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
exit 0