Skip to content

Commit

Permalink
See Released PR labels to identify if the PR is already released
Browse files Browse the repository at this point in the history
  • Loading branch information
soutaro committed Jul 5, 2023
1 parent 1978794 commit ff24623
Showing 1 changed file with 45 additions and 1 deletion.
46 changes: 45 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ end
Rake::Task[:release].enhance do
Rake::Task[:"release:note"].invoke
Rake::Task[:"release:github"].invoke
Rake::Task[:"release:release-prs"].invoke
end

desc "Generate changelog template from GH pull requests"
Expand All @@ -48,7 +49,7 @@ task :changelog do
"--json",
"url,title,number",
"--search" ,
"milestone:\"#{milestone}\" is:merged sort:updated-desc"
"milestone:\"#{milestone}\" is:merged sort:updated-desc -label:Released"
]

require "open3"
Expand Down Expand Up @@ -173,4 +174,47 @@ NOTES
puts
end
end

desc "Add `Released` labels to pull requests associated to the version"
task "release-prs" do
major, minor, patch, pre = Steep::VERSION.split(".", 4)
major = major.to_i
minor = minor.to_i
patch = patch.to_i

if patch == 0
milestone = "Steep #{major}.#{minor}"
else
milestone = "Steep #{major}.#{minor}.x"
end

puts "🔍 Finding pull requests that is associated to milestone `#{milestone}`..."

command = [
"gh",
"pr",
"list",
"--json",
"url,title,number",
"--search" ,
"milestone:\"#{milestone}\" is:merged sort:updated-desc -label:Released"
]

require "open3"
output, status = Open3.capture2(*command)
raise status.inspect unless status.success?

require "json"
json = JSON.parse(output, symbolize_names: true)

puts " ✅ Found #{json.size} PRs..."

json.each do |pr|
puts "🧐 Updating #{pr[:url]}..."
output, status = Open3.capture2("gh", "pr", "edit", pr[:number].to_s, "--add-label", "Released")
raise status.inspect unless status.success?
puts " ✅ Done!"
sleep 0.5
end
end
end

0 comments on commit ff24623

Please sign in to comment.