generated from rochacbruno/python-project-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding the automatic next version detection
- Loading branch information
Showing
2 changed files
with
36 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#!/bin/bash | ||
|
||
# Get the list of tags and sort them in version order | ||
LATEST_TAG=$(git tag -l | sort -V | tail -n1) | ||
|
||
# Split the tag into major, minor, and patch versions | ||
IFS='.' read -ra ADDR <<< "$LATEST_TAG" | ||
MAJOR=${ADDR[0]} | ||
MINOR=${ADDR[1]} | ||
PATCH=${ADDR[2]} | ||
|
||
# Decide which part to increment based on the passed argument | ||
case "$1" in | ||
--major) | ||
MAJOR=$((MAJOR+1)) | ||
MINOR=0 | ||
PATCH=0 | ||
;; | ||
--minor) | ||
MINOR=$((MINOR+1)) | ||
PATCH=0 | ||
;; | ||
--patch) | ||
PATCH=$((PATCH+1)) | ||
;; | ||
*) | ||
# By default increment minor version | ||
MINOR=$((MINOR+1)) | ||
PATCH=0 | ||
;; | ||
esac | ||
|
||
# Print the next version | ||
echo "$MAJOR.$MINOR.$PATCH" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters