Skip to content

Commit

Permalink
feat: bump version and generate CHANGELOG with the version
Browse files Browse the repository at this point in the history
- add `no` option to bump task
- add `future_release` option to changelog task
  • Loading branch information
iberianpig committed Nov 6, 2023
1 parent dc50ce4 commit a94cc49
Showing 1 changed file with 26 additions and 18 deletions.
44 changes: 26 additions & 18 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,37 +8,45 @@ task default: :spec

desc "bump version and generate CHANGELOG with the version"
task :bump, :type do |_, args|
require "bump"
label = args[:type]
unless %w[major minor patch pre].include?(label)
raise "Usage: rake bump[LABEL] (LABEL: ['major', 'minor', 'patch', 'pre'])"
unless %w[major minor patch pre no].include?(label)
raise "Usage: rake bump[LABEL] (LABEL: ['major', 'minor', 'patch', 'pre', 'no'])"
end

require "bump"
puts "Bump version to #{label}"
Bump::Bump.run(label)
puts 'Next step: "bundle exec rake release_tag"'
end

desc "Create and Push tag"
task :release_tag do
require "bundler/gem_tasks"
Rake::Task["release:source_control_push"].invoke
puts 'Next step: "bundle exec rake generate_changelog"'
end
next_version = if label == "no"
Bump::Bump.current
else
Bump::Bump.next_version(label)
end

desc "Generate CHANGELOG.md"
task :generate_changelog do
require "github_changelog_generator/task"

GitHubChangelogGenerator::RakeTask.new :changelog do |config|
gemspec_path = Dir.glob(File.join(File.dirname(File.expand_path(__FILE__)), "*.gemspec")).first
gemspec = Gem::Specification.load(gemspec_path)
config.user = gemspec.authors.first
config.project = gemspec.name
config.future_release = next_version
end

Rake::Task[:changelog].execute

puts "update CHANGELOG"
`git add CHANGELOG.md && git commit -m "docs(CHANGELOG) update"`
`git add CHANGELOG.md`

if label == "no"
puts "No bump version"
`git commit -m "update CHANGELOG"`
else
puts "Bump version to #{label}"
Bump::Bump.run(label)
end

puts 'Next step: "bundle exec rake release_tag"'
end

desc "Create and Push tag"
task :release_tag do
require "bundler/gem_tasks"
Rake::Task["release:source_control_push"].invoke
end

0 comments on commit a94cc49

Please sign in to comment.