Frank refactoring part 1
This commit is contained in:
Executable
+47
@@ -0,0 +1,47 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
parent_path=$( cd "$(dirname "${BASH_SOURCE[0]}")" || exit ; pwd -P )
|
||||
cd "$parent_path" || exit
|
||||
|
||||
last_commit_subject=$(git log -1 --format=%s)
|
||||
if [[ "$last_commit_subject" =~ ^Version\ Bump ]]; then
|
||||
echo "Last commit is already a version bump (\"$last_commit_subject\"). Nothing to do."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ 1 -eq "$#" ]
|
||||
then
|
||||
current_version=$(grep -m 1 '^version = ' pyproject.toml | sed -E 's/version = "([^"]+)"/\1/')
|
||||
IFS='.' read -r major minor patch <<< "$current_version"
|
||||
|
||||
if [ "$1" == "major" ]; then
|
||||
major=$((major + 1))
|
||||
minor=0
|
||||
patch=0
|
||||
new_version="${major}.${minor}.${patch}"
|
||||
elif [ "$1" == "minor" ]; then
|
||||
minor=$((minor + 1))
|
||||
patch=0
|
||||
new_version="${major}.${minor}.${patch}"
|
||||
elif [ "$1" == "patch" ]; then
|
||||
patch=$((patch + 1))
|
||||
new_version="${major}.${minor}.${patch}"
|
||||
elif [[ "$1" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
||||
new_version="$1"
|
||||
else
|
||||
echo "Invalid argument: must be 'major', 'minor', 'patch', or a specific version (e.g. 1.2.3)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Version bump from $current_version to $new_version"
|
||||
sed --in-place --regexp-extended 's/version = "([0-9]{1,2}.[0-9]+.[0-9]+)"/version = "'"$new_version"'"/g' pyproject.toml
|
||||
git add pyproject.toml
|
||||
git commit -m "Version Bump v$new_version (frank)"
|
||||
git tag "frank-v$new_version"
|
||||
else
|
||||
echo "No version bump"
|
||||
echo "Usage: $0 <major|minor|patch|version_string>"
|
||||
exit 1
|
||||
fi
|
||||
git push
|
||||
git push --tags
|
||||
Reference in New Issue
Block a user