Skip to content

Instantly share code, notes, and snippets.

@darnould
Last active February 21, 2020 16:14
Show Gist options
  • Save darnould/ae4d33c49b1a91fbd3c1 to your computer and use it in GitHub Desktop.
Save darnould/ae4d33c49b1a91fbd3c1 to your computer and use it in GitHub Desktop.
Quick major/minor/patch bumping demo
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 "."
@revett
Copy link

revett commented Jun 22, 2015

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment