-
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.
Merge pull request #85 from KIT-MRT/version_bump_via_pr_description
Bump the version using the #flags from the PR description
- Loading branch information
Showing
2 changed files
with
60 additions
and
30 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
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,39 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
if [[ $# -ne 2 ]]; then | ||
echo "Usage: $0 <version> <input_string>" | ||
exit 1 | ||
fi | ||
|
||
initial_version=${1//[^0-9.]/} | ||
input_string=${2//[^a-zA-Z0-9#]/} | ||
|
||
initial_major=$(echo "$initial_version" | cut -d'.' -f1) | ||
initial_minor=$(echo "$initial_version" | cut -d'.' -f2) | ||
initial_patch=$(echo "$initial_version" | cut -d'.' -f3) | ||
|
||
# Determine the bump type based on input string | ||
if [[ "$input_string" == *"#major"* ]]; then | ||
new_major=$((initial_major + 1)) | ||
new_minor=0 | ||
new_patch=0 | ||
elif [[ "$input_string" == *"#minor"* ]]; then | ||
new_major=$initial_major | ||
new_minor=$((initial_minor + 1)) | ||
new_patch=0 | ||
elif [[ "$input_string" == *"#patch"* ]]; then | ||
new_major=$initial_major | ||
new_minor=$initial_minor | ||
new_patch=$((initial_patch + 1)) | ||
else | ||
# Default to minor bump | ||
new_major=$initial_major | ||
new_minor=$((initial_minor + 1)) | ||
new_patch=0 | ||
fi | ||
|
||
new_version="v${new_major}.${new_minor}.${new_patch}" | ||
echo "${new_version}" | ||
|