diff options
author | Toby Vincent <tobyv@tobyvin.dev> | 2024-01-16 18:01:35 -0600 |
---|---|---|
committer | Toby Vincent <tobyv@tobyvin.dev> | 2024-01-16 18:01:35 -0600 |
commit | bb95ed0110cc28c00a17799f5c976ed8ab0ab473 (patch) | |
tree | 950d55ac3072012ea2d351916b6dc3e09a396e47 | |
parent | 91db44d0d73c3808cedfed3759cd06433107b456 (diff) |
feat(git): add bump subcommand
-rwxr-xr-x | git/.local/bin/git-bump | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/git/.local/bin/git-bump b/git/.local/bin/git-bump new file mode 100755 index 0000000..d75a755 --- /dev/null +++ b/git/.local/bin/git-bump @@ -0,0 +1,27 @@ +#!/bin/sh + +tag="$(git describe --abbrev=0 2>/dev/null)" +IFS=. read -r major minor patch <<EOF +${tag#v} +EOF + +case "$1" in +major) + major=$((major + 1)) + minor=0 + patch=0 + ;; +minor) + minor=$((minor + 1)) + patch=0 + ;; +patch) + patch=$((patch + 1)) + ;; +*) + echo "Invalid semver argument given (major|minor|patch): $1" 1>&2 + exit 1 + ;; +esac + +git shortlog "$tag"..HEAD | git tag -s "v${major}.${minor}.${patch}" --file - |