mirror of
https://github.com/jmagar/unraid-mcp
synced 2026-04-21 13:37:53 +00:00
- bin/bump-version.sh: one-command version bump across all four files; supports explicit version or major/minor/patch keywords; uses CLAUDE_PLUGIN_ROOT when set (hook context), dirname fallback otherwise - tests/test_bump_version.bats: 9 bats tests covering all bump modes, all-files-in-sync, output format, and dirname fallback - scripts/ renamed to bin/ - Bump 1.3.5 → 1.3.6
61 lines
1.8 KiB
Bash
Executable file
61 lines
1.8 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
# bump-version.sh — update version in all version-bearing files atomically.
|
|
#
|
|
# Usage:
|
|
# ./bin/bump-version.sh 1.3.5
|
|
# ./bin/bump-version.sh patch # auto-increment patch
|
|
# ./bin/bump-version.sh minor # auto-increment minor
|
|
# ./bin/bump-version.sh major # auto-increment major
|
|
|
|
set -euo pipefail
|
|
|
|
REPO_ROOT="${CLAUDE_PLUGIN_ROOT:-$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)}"
|
|
|
|
VERSION_FILES=(
|
|
"${REPO_ROOT}/pyproject.toml"
|
|
"${REPO_ROOT}/.claude-plugin/plugin.json"
|
|
"${REPO_ROOT}/.codex-plugin/plugin.json"
|
|
"${REPO_ROOT}/.gemini-extension.json"
|
|
)
|
|
|
|
# Resolve gemini path (handles both naming conventions)
|
|
if [ -f "${REPO_ROOT}/gemini-extension.json" ]; then
|
|
VERSION_FILES[3]="${REPO_ROOT}/gemini-extension.json"
|
|
fi
|
|
|
|
current_version() {
|
|
grep -m1 '"version"' "${REPO_ROOT}/.claude-plugin/plugin.json" \
|
|
| sed 's/.*"version": "\(.*\)".*/\1/'
|
|
}
|
|
|
|
bump() {
|
|
local version="$1" part="$2"
|
|
local major minor patch
|
|
IFS='.' read -r major minor patch <<< "$version"
|
|
case "$part" in
|
|
major) echo "$((major + 1)).0.0" ;;
|
|
minor) echo "${major}.$((minor + 1)).0" ;;
|
|
patch) echo "${major}.${minor}.$((patch + 1))" ;;
|
|
esac
|
|
}
|
|
|
|
# Resolve new version
|
|
ARG="${1:-}"
|
|
CURRENT="$(current_version)"
|
|
|
|
case "$ARG" in
|
|
major|minor|patch) NEW="$(bump "$CURRENT" "$ARG")" ;;
|
|
"") echo "Usage: $0 <version|major|minor|patch>"; exit 1 ;;
|
|
*) NEW="$ARG" ;;
|
|
esac
|
|
|
|
echo "Bumping $CURRENT → $NEW"
|
|
|
|
for file in "${VERSION_FILES[@]}"; do
|
|
[ -f "$file" ] || { echo " skip (not found): $file"; continue; }
|
|
sed -i "s/\"version\": \"${CURRENT}\"/\"version\": \"${NEW}\"/" "$file"
|
|
sed -i "s/^version = \"${CURRENT}\"/version = \"${NEW}\"/" "$file"
|
|
echo " updated: ${file#"${REPO_ROOT}/"}"
|
|
done
|
|
|
|
echo "Done. Don't forget to add a CHANGELOG.md entry for ${NEW}."
|