Rake task to bump version number
We recently published our first open source chef cookbook chef-thumbor. As part of the deployment process we have to bump the version number which we automated with following rake task.
Don't for forget to add versionomy
to your Gemfile
.
desc 'Bump version number'
task :bump, :type do |t, args|
args.with_defaults(:type => :tiny)
content = File.read('metadata.rb')
version_pattern = /(version.*?')(.*?)(')/
current_version = content.match(version_pattern)[2]
next_version = Versionomy.parse(Regexp.last_match[2]).bump(args.type).to_s
File.write('metadata.rb', content.gsub(version_pattern, "\\1#{next_version}\\3"))
puts "Successfully bumped from #{current_version} to #{next_version}!"
end
Written by Enrico Stahn
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Ruby
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#