Skip to content

Commit

Permalink
bump version script #64
Browse files Browse the repository at this point in the history
  • Loading branch information
frosklis committed Mar 20, 2021
1 parent 8c17c0b commit d3ae240
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions scripts/ci_bump_version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# $1 - semver string
# $2 - level to incr {release,minor,major} - release by default
function bump_version() {
local RE='[^0-9]*\([0-9]*\)[.]\([0-9]*\)[.]\([0-9]*\)\([0-9A-Za-z-]*\)'
major=`echo $1 | sed -e "s#$RE#\1#"`
minor=`echo $1 | sed -e "s#$RE#\2#"`
release=`echo $1 | sed -e "s#$RE#\3#"`
# patch=`echo $1 | sed -e "s#$RE#\4#"`

release=0
minor=$((minor+1))

echo "$major.$minor.$release"
}

version=$(grep -E "version = \"([0-9]+\.[0-9]+.[0-9]+)\"" Cargo.toml | grep -Eo -m 1 "[0-9]+\.[0-9]+.[0-9]+")
bumped=$(bump_version ${version})
message="Bump from $version to $bumped"
commit_message="[ci skip] ${message}"

# Update Cargo.toml
line_number=$(grep -En "version = \"([0-9]+\.[0-9]+.[0-9]+)\"" Cargo.toml | grep -Eo -m 1 "[0-9]+" | head -n 1)

sed -i "${line_number}s/.*/version = \"${bumped}\"/" Cargo.toml

# Update Changelog
sed -i "3i## [${bumped}] - xxx" CHANGELOG.md

echo ${commit_message}

0 comments on commit d3ae240

Please sign in to comment.