release

 1#!/usr/bin/env bash
 2
 3# Parse command line arguments
 4minor=false
 5while [ "$#" -gt 0 ]; do
 6  case "$1" in
 7    --minor) minor=true; shift 1;;
 8    *) echo "Unknown parameter: $1"; exit 1;;
 9  esac
10done
11
12git fetch --force --tags
13
14# Get the latest Git tag
15latest_tag=$(git tag --sort=committerdate | grep -E '[0-9]' | tail -1)
16
17# If there is no tag, exit the script
18if [ -z "$latest_tag" ]; then
19    echo "No tags found"
20    exit 1
21fi
22
23echo "Latest tag: $latest_tag"
24
25# Split the tag into major, minor, and patch numbers
26IFS='.' read -ra VERSION <<< "$latest_tag"
27
28if [ "$minor" = true ]; then
29    # Increment the minor version and reset patch to 0
30    minor_number=${VERSION[1]}
31    let "minor_number++"
32    new_version="${VERSION[0]}.$minor_number.0"
33else
34    # Increment the patch version
35    patch_number=${VERSION[2]}
36    let "patch_number++"
37    new_version="${VERSION[0]}.${VERSION[1]}.$patch_number"
38fi
39
40echo "New version: $new_version"
41
42git tag $new_version
43git push --tags