Skip to content

Instantly share code, notes, and snippets.

@unRob
Created November 1, 2017 02:02
Show Gist options
  • Save unRob/3a14b304e078f9443dfd351d49354428 to your computer and use it in GitHub Desktop.
Save unRob/3a14b304e078f9443dfd351d49354428 to your computer and use it in GitHub Desktop.
♥ << ruby
#!/usr/bin/env ruby
# git tag -l => 0.0.0
# version.rb patch => 0.0.1
# version.rb minor => 0.1.0
# version.rb major => 1.0.0
increments = [:major, :minor, :patch]
increment = ARGV[0].to_sym
raise ArgumentError.new(increments.join(' ')) unless increments.include? increment
components = %x{git describe --abbrev=0}.split(".").map(&:to_i)
components[ increments.index increment ] += 1
puts components.join('.')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment