-
Notifications
You must be signed in to change notification settings - Fork 125
chore(releasing): publish to crates.io after prep PR is merged #1783
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -123,33 +123,18 @@ fn release(version_arg: Option<&str>, dry_run: bool, issue: Option<&str>) -> Res | |
| &root, | ||
| )?; | ||
|
|
||
| println!("Publishing to crates.io..."); | ||
| run("cargo", &["publish"], &root)?; | ||
| println!("Published vrl v{new_version} to crates.io."); | ||
|
|
||
| let tag = format!("v{new_version}"); | ||
| run( | ||
| "git", | ||
| &["tag", "-a", &tag, "-m", &format!("Release {new_version}")], | ||
| &root, | ||
| )?; | ||
|
|
||
| println!("Pushing..."); | ||
| run("git", &["push", "-u", "origin", &branch], &root)?; | ||
| run("git", &["push", "origin", &tag], &root)?; | ||
|
|
||
| println!("Creating pull request..."); | ||
| let title = format!("chore(releasing): Prepare {new_version} release"); | ||
| let mut body = formatdoc! {" | ||
| Release {new_version} | ||
|
|
||
| Published to crates.io: https://crates.io/crates/vrl/{new_version} | ||
| Tag: `{tag}`" | ||
| Release {new_version}" | ||
| }; | ||
| if let Some(link) = issue { | ||
| body.push_str(&format!("\n\nRelated issue: {link}")); | ||
| } | ||
| run( | ||
| let pr_url = run( | ||
| "gh", | ||
| &[ | ||
| "pr", | ||
|
|
@@ -167,8 +152,46 @@ fn release(version_arg: Option<&str>, dry_run: bool, issue: Option<&str>) -> Res | |
| ], | ||
| &root, | ||
| )?; | ||
| let pr_url = pr_url.trim().to_string(); | ||
| println!("PR: {pr_url}"); | ||
|
|
||
| println!("Waiting for the PR to be merged to main..."); | ||
| loop { | ||
| let state = run( | ||
| "gh", | ||
| &["pr", "view", &pr_url, "--json", "state", "--jq", ".state"], | ||
| &root, | ||
| )?; | ||
| if state.trim() == "MERGED" { | ||
| println!("PR merged."); | ||
| break; | ||
| } | ||
| println!(" state: {}. Checking again in 15s...", state.trim()); | ||
| std::thread::sleep(std::time::Duration::from_secs(15)); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💭 Can we avoid polling? I am thinking if we can use the tag as a trigger for a publish workflow. |
||
| } | ||
|
|
||
| println!("Switching to main..."); | ||
| run("git", &["checkout", "main"], &root)?; | ||
| run("git", &["pull", "origin", "main"], &root)?; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When another PR lands on Useful? React with 👍 / 👎. |
||
|
|
||
| let tag = format!("v{new_version}"); | ||
| run( | ||
| "git", | ||
| &["tag", "-a", &tag, "-m", &format!("Release {new_version}")], | ||
| &root, | ||
| )?; | ||
|
Comment on lines
+178
to
+182
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
If Useful? React with 👍 / 👎. |
||
|
|
||
| run("git", &["checkout", &tag], &root)?; | ||
|
|
||
| println!("Publishing to crates.io..."); | ||
| run("cargo", &["publish"], &root)?; | ||
| println!("Published vrl v{new_version} to crates.io."); | ||
|
|
||
| run("git", &["push", "origin", &tag], &root)?; | ||
|
|
||
| println!("\nRelease {new_version} complete!"); | ||
| println!("Tag: {tag}"); | ||
| println!("crates.io: https://crates.io/crates/vrl/{new_version}"); | ||
| Ok(()) | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the release flow where the prep PR is closed instead of merged (for example reviewers reject it or a maintainer recreates the PR), this loop never exits because it treats every non-
MERGEDgh pr view --json stateresult as still pending; the GitHub CLI exposes closed PRs through this samestatefield. That leaves the release command polling forever rather than failing before tagging/publishing can be retried or corrected.Useful? React with 👍 / 👎.