Skip to content

Commit

Permalink
Bring back bump script
Browse files Browse the repository at this point in the history
It's used to release CF buildpacks.
Deleted in error in #386
  • Loading branch information
arjun024 committed Jul 16, 2024
1 parent c48efb5 commit 874d9f4
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions scripts/bump
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/bin/env ruby
# encoding: utf-8

require 'tempfile'
require_relative '../lib/commit'

old_version = File.open('VERSION', 'r') { |f| f.readline.chomp }

version_parts = old_version.match(/(\d+\.\d+\.)(\d+)/)
new_version = version_parts[1] + (version_parts[2].to_i + 1).to_s

File.open('VERSION', 'w') { |f| f.write new_version }

new_changelog = Tempfile.new('CHANGELOG')
begin
heading = "v#{new_version} #{Time.now.strftime('%b %d, %Y')}\n"
new_changelog.write heading
new_changelog.write '=' * heading.length
new_changelog.write "\n\n"

commits = Commit.recent(old_version) rescue nil
if commits
commits.each do |commit|
new_changelog.write commit.to_s
new_changelog.write "\n\n"
end
else
log = `git log v#{old_version}..HEAD`
new_changelog.write log
end

new_changelog.write "\n"

File.open('CHANGELOG', 'a+').each { |line| new_changelog.write line }
ensure
new_changelog.close
end

`cp #{new_changelog.path} CHANGELOG`

puts "Bumped to #{`cat VERSION`}"

0 comments on commit 874d9f4

Please sign in to comment.