Skip to content

Commit

Permalink
add determineNextVersion function
Browse files Browse the repository at this point in the history
  • Loading branch information
antoooks committed Feb 3, 2024
1 parent ceeddd4 commit 3d1dbd9
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion releasing/create-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,9 @@ function create_release {
# Take everything after the last slash.
version=${git_tag##*/}

release_branch="release-${module}/${version}"
determineNextVersion $@

release_branch="release-${module}/${nextVersion}"

# Create release branch release-{module}/{version}
echo "Creating release..."
Expand Down Expand Up @@ -147,5 +149,27 @@ function create_release {
--notes-file "$changelog_file"
}

function determineNextVersion {
currentTag=$(git tag --list "${module}*" --sort=-creatordate | head -n1)
currentVersion=$(echo ${currentTag##*/} | cut -d'v' -f2)
majorVer=$(echo $currentVersion | cut -d'.' -f1)
minorVer=$(echo $currentVersion | cut -d'.' -f2)
patchVer=$(echo $currentVersion | cut -d'.' -f3)

if [[ ${release_type} == "major" ]]; then
majorVer="$(($majorVer + 1))"
elif [[ ${release_type} == "minor" ]]; then
minorVer="$(($minorVer + 1))"
elif [[ ${release_type} == "patch" ]]; then
patchVer="$(($patchVer + 1))"
else
echo "Error: release_type not supported. Available values 'major', 'minor', 'patch'"
exit 1
fi

nextVersion="$majorVer.$minorVer.$patchVer"
return
}

## create release
create_release "$git_tag"

0 comments on commit 3d1dbd9

Please sign in to comment.