Skip to content

Commit

Permalink
Add rake task to cut releases
Browse files Browse the repository at this point in the history
  • Loading branch information
marcandre committed May 12, 2020
1 parent 0715c24 commit 9fdd18c
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ source 'https://rubygems.org'

gemspec

gem 'bump', require: false
gem 'pry'
gem 'rake', '~> 12.0'
gem 'rspec', '~> 3.7'
Expand Down
35 changes: 35 additions & 0 deletions tasks/cut_release.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# frozen_string_literal: true

require 'bump'

namespace :cut_release do
%w[major minor patch pre].each do |release_type|
desc "Cut a new #{release_type} release, create release notes " \
'and update documents.'
task release_type do
run(release_type)
end
end

def add_header_to_changelog(version)
changelog = File.read('CHANGELOG.md')
head, tail = changelog.split("## master (unreleased)\n\n", 2)

File.open('CHANGELOG.md', 'w') do |f|
f << head
f << "## master (unreleased)\n\n"
f << "## #{version} (#{Time.now.strftime('%F')})\n\n"
f << tail
end
end

def run(release_type)
old_version = Bump::Bump.current
Bump::Bump.run(release_type, commit: false, bundle: false, tag: false)
new_version = Bump::Bump.current

add_header_to_changelog(new_version)

puts "Changed version from #{old_version} to #{new_version}."
end
end

0 comments on commit 9fdd18c

Please sign in to comment.