Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up release automation #1424

Merged
merged 3 commits into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 0 additions & 44 deletions .github/scripts/release-workflow-package-push.sh

This file was deleted.

94 changes: 0 additions & 94 deletions .github/scripts/release-workflow-prepare-pr.sh

This file was deleted.

56 changes: 2 additions & 54 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -68,64 +68,12 @@ end
namespace :buildpack do
desc "prepares the next version of the buildpack for release"
task :prepare do
deploy = DeployCheck.new(github: "heroku/heroku-buildpack-ruby")
unreleased_changelogs = Pathname(__dir__).join("changelogs/unreleased").glob("*.md")
if unreleased_changelogs.empty?
puts "No devcenter changelog entries on disk in changelogs/unreleased"
else
next_changelog_dir = Pathname(__dir__).join("changelogs").join(deploy.next_version.to_s)

next_changelog_dir.mkpath

unreleased_changelogs.each do |source|
dest = next_changelog_dir.join(source.basename)
puts "Moving #{source} to #{dest}"
FileUtils.mv(source, dest)
end
end

changelog_md = Pathname(__dir__).join("CHANGELOG.md")
contents = changelog_md.read
version_string = "## #{deploy.next_version}"
if contents.include?(version_string)
puts "Found an entry in CHANGELOG.md for #{version_string}"
else
new_section = "## Main (unreleased)\n\n#{version_string} (#{Time.now.strftime("%Y/%m/%d")})"

puts "Writing to CHANGELOG.md:\n\n#{new_section}"

changelog_md.write(contents.gsub("## Main (unreleased)", new_section))
end

version_rb = Pathname(__dir__).join("lib/language_pack/version.rb")
puts "Updating version.rb"
contents = version_rb.read.gsub(/BUILDPACK_VERSION = .*$/, %Q{BUILDPACK_VERSION = "#{deploy.next_version.to_s}"})
version_rb.write(contents)
puts("Use https://github.com/heroku/heroku-buildpack-ruby/actions/workflows/prepare-release.yml")
end

desc "releases the next version of the buildpack"
task :release do
deploy = DeployCheck.new(github: "heroku/heroku-buildpack-ruby")
puts "Attempting to deploy #{deploy.next_version}, overwrite with RELEASE_VERSION env var"
deploy.check!

if deploy.push_tag?
sh("git tag -f #{deploy.next_version}") do |out, status|
raise "Could not `git tag -f #{deploy.next_version}`: #{out}" unless status.success?
end
sh("git push --tags") do |out, status|
raise "Could not `git push --tags`: #{out}" unless status.success?
end
end

command = "heroku buildpacks:publish heroku/ruby #{deploy.next_version}"
puts "Releasing to heroku: `#{command}`"
exec(command)
end
desc "stage a tarball of the buildpack, this runs on github actions to deploy CNB"
task :tarball do
tarballer = Tarballer.new(name: "heroku-buildpack-ruby", directory: __dir__)
tarballer.call
puts("Use https://github.com/heroku/heroku-buildpack-ruby/actions/workflows/prepare-release.yml")
end
end

Expand Down
4 changes: 2 additions & 2 deletions lib/rake/deploy_check.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ def check_branch!(name = "main")

# Raises an error if the changelog does not have an entry with the designated version
def check_changelog!
if !File.read("CHANGELOG.md").include?("## #{next_version}")
raise "Expected CHANGELOG.md to include #{next_version} but it did not"
if !File.read("CHANGELOG.md").include?("## [#{next_version}]")
raise "Expected CHANGELOG.md to include [#{next_version}] but it did not"
end
end

Expand Down
4 changes: 2 additions & 2 deletions spec/rake/deploy_check_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,9 @@ def deploy.remote_tag_array; [ "v123" ] ; end
run!("touch CHANGELOG.md")
expect {
deploy.check_changelog!
}.to raise_error(/Expected CHANGELOG.md to include v999/)
}.to raise_error(/Expected CHANGELOG.md to include \[v999\]/)

run!("echo '## v999' >> CHANGELOG.md")
run!("echo '## [v999]' >> CHANGELOG.md")
deploy.check_changelog!
end
end
Expand Down
Loading