Merge pull request #16530 from trail-of-forks/joesweeney/provenance-on-publish

Add option to retain tmpdir on pr-pull
This commit is contained in:
Mike McQuaid 2024-01-26 14:02:12 +00:00 committed by GitHub
commit 8c2dcbac3d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -45,6 +45,8 @@ module Homebrew
switch "--warn-on-upload-failure", switch "--warn-on-upload-failure",
description: "Warn instead of raising an error if the bottle upload fails. " \ description: "Warn instead of raising an error if the bottle upload fails. " \
"Useful for repairing bottle uploads that previously failed." "Useful for repairing bottle uploads that previously failed."
switch "--retain-bottle-dir",
description: "Does not clean up the tmp directory for the bottle so it can be used later."
flag "--committer=", flag "--committer=",
description: "Specify a committer name and email in `git`'s standard author format." description: "Specify a committer name and email in `git`'s standard author format."
flag "--message=", flag "--message=",
@ -444,7 +446,8 @@ module Homebrew
pr_check_conflicts("#{user}/#{repo}", pr) pr_check_conflicts("#{user}/#{repo}", pr)
ohai "Fetching #{tap} pull request ##{pr}" ohai "Fetching #{tap} pull request ##{pr}"
Dir.mktmpdir pr do |dir| dir = Dir.mktmpdir pr
begin
cd dir do cd dir do
current_branch_head = ENV["GITHUB_SHA"] || tap.git_head current_branch_head = ENV["GITHUB_SHA"] || tap.git_head
original_commit = if args.no_cherry_pick? original_commit = if args.no_cherry_pick?
@ -501,6 +504,15 @@ module Homebrew
upload_args << "--root-url-using=#{args.root_url_using}" if args.root_url_using upload_args << "--root-url-using=#{args.root_url_using}" if args.root_url_using
safe_system HOMEBREW_BREW_FILE, *upload_args safe_system HOMEBREW_BREW_FILE, *upload_args
end end
ensure
if args.retain_bottle_dir? && ENV["GITHUB_ACTIONS"]
ohai "Bottle files retained at:", dir
File.open(ENV.fetch("GITHUB_OUTPUT"), "a") do |f|
f.puts "bottle_path=#{dir}"
end
else
FileUtils.remove_entry dir
end
end end
end end
end end