Skip to content

A platform for community discussion. Free, open, simple.

DEV: Label automated release PRs (#36904)

David Taylor9c4553c9adf7
diff --git a/lib/tasks/release.rake b/lib/tasks/release.rake
index 9dd2e3f73bf..1ddc69742bf 100644
--- a/lib/tasks/release.rake
+++ b/lib/tasks/release.rake
@@ -3,6 +3,7 @@
module ReleaseUtils
PRIMARY_RELEASE_TAG = "release"
RELEASE_TAGS = [PRIMARY_RELEASE_TAG, "beta", "latest-release"].freeze
+ PR_LABEL = "release"
def self.dry_run?
!!ENV["DRY_RUN"]
@@ -36,6 +37,12 @@ module ReleaseUtils
stdout
end
+ def self.gh(*args)
+ puts "> gh #{args.inspect}"
+ return true if test_mode?
+ system "gh", *args
+ end
+
def self.ref_exists?(ref)
git "rev-parse", "--verify", ref
true
@@ -44,9 +51,7 @@ module ReleaseUtils
end
def self.make_pr(base:, branch:)
- return if test_mode?
-
- args = [
+ title_and_body = [
"--title",
git("log", "-1", branch, "--pretty=%s").strip,
"--body",
@@ -54,8 +59,8 @@ module ReleaseUtils
]
success =
- system("gh", "pr", "create", "--base", base, "--head", branch, *args) ||
- system("gh", "pr", "edit", branch, *args)
+ gh("pr", "create", "--base", base, "--head", branch, *title_and_body, "--label", PR_LABEL) ||
+ gh("pr", "edit", branch, *title_and_body, "--add-label", PR_LABEL)
raise "Failed to create or update PR" unless success
end
diff --git a/spec/tasks/release_spec.rb b/spec/tasks/release_spec.rb
index a9bd9b5ea69..3166e5c04a5 100644
--- a/spec/tasks/release_spec.rb
+++ b/spec/tasks/release_spec.rb
@@ -191,7 +191,9 @@ RSpec.describe "tasks/version_bump" do
end
end
- it "creates version-bump/main branch with proper commit message" do
+ it "creates version-bump/main branch with proper commit message and PR" do
+ allow(ReleaseUtils).to receive(:gh).with("pr", "create", any_args).and_return(true)
+
Dir.chdir(local_path) do
File.write("lib/version.rb", fake_version_rb("2025.05.0-latest"))
run "git", "add", "."
@@ -215,6 +217,49 @@ RSpec.describe "tasks/version_bump" do
"Merging this will trigger the creation of a `release/2025.05` branch on the preceding commit.",
)
end
+
+ expect(ReleaseUtils).to have_received(:gh).with(
+ "pr",
+ "create",
+ "--base",
+ "main",
+ "--head",
+ "version-bump/main",
+ "--title",
+ "DEV: Begin development of v2025.10.0-latest",
+ "--body",
+ a_string_including("Merging this will trigger the creation of a `release/2025.05` branch"),
+ "--label",
+ ReleaseUtils::PR_LABEL,
+ )
+ end
+
+ it "falls back to editing PR if create fails" do
+ allow(ReleaseUtils).to receive(:gh).with("pr", "create", any_args).and_return(false)
+ allow(ReleaseUtils).to receive(:gh).with("pr", "edit", any_args).and_return(true)
+
+ Dir.chdir(local_path) do
+ File.write("lib/version.rb", fake_version_rb("2025.05.0-latest"))
+ run "git", "add", "."
+ run "git", "commit", "-m", "previous version"
+ run "git", "push", "origin", "main"
+
+ freeze_time Time.utc(2025, 10, 15) do
+ capture_stdout { invoke_rake_task("release:prepare_next_version") }
+ end
+ end
+
+ expect(ReleaseUtils).to have_received(:gh).with(
+ "pr",
+ "edit",
+ "version-bump/main",
+ "--title",
+ "DEV: Begin development of v2025.10.0-latest",
+ "--body",
+ a_string_including("Merging this will trigger the creation of a `release/2025.05` branch"),
+ "--add-label",
+ ReleaseUtils::PR_LABEL,
+ )
end
end
end