Last active
February 21, 2020 16:14
-
-
Save darnould/ae4d33c49b1a91fbd3c1 to your computer and use it in GitHub Desktop.
Quick major/minor/patch bumping demo
This file contains hidden or 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
bump_index = { "major" => 0, "minor" => 1, "patch" => 2 } | |
bump_type = ARGV[0] | |
bump_index.include?(bump_type) or abort "Usage: #{$0} major/minor/patch" | |
bump_start = bump_index[bump_type] | |
# Preset in this example | |
version = "1.2.3" | |
version_indexes = version.split(".").map &:to_i | |
version_indexes[bump_start] += 1 | |
bump_start.succ.upto(2) do |i| | |
version_indexes[i] = 0 | |
end | |
puts version_indexes.join "." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
👍