|
2 | 2 |
|
3 | 3 | extern crate toml; |
4 | 4 |
|
| 5 | +use std::env; |
5 | 6 | use std::fs; |
6 | | -use std::io; |
7 | 7 | use std::process::Command; |
8 | 8 | use std::thread::sleep; |
9 | 9 | use std::time::Duration; |
@@ -120,33 +120,29 @@ fn ensure_versions_are_unpublished(version: &str) -> Result<(), Box<dyn std::err |
120 | 120 | Ok(()) |
121 | 121 | } |
122 | 122 |
|
123 | | -fn read_line_trimmed() -> Result<String, Box<dyn std::error::Error>> { |
124 | | - let mut input = String::new(); |
125 | | - io::stdin().read_line(&mut input)?; |
126 | | - Ok(input.trim().to_string()) |
127 | | -} |
128 | | - |
129 | 123 | fn main() -> Result<(), Box<dyn std::error::Error>> { |
130 | | - ensure_clean_worktree()?; |
131 | | - |
132 | | - println!("Enter target version (e.g. 1.0.0):"); |
133 | | - let target_version = read_line_trimmed()?; |
134 | | - if target_version.is_empty() { |
135 | | - return Err("Target version cannot be empty".into()); |
| 124 | + let args: Vec<String> = env::args().collect(); |
| 125 | + if args.len() > 2 { |
| 126 | + return Err(format!( |
| 127 | + "Usage: {} [expected_version]", |
| 128 | + args.first().map(String::as_str).unwrap_or("publish.rs") |
| 129 | + ) |
| 130 | + .into()); |
136 | 131 | } |
137 | 132 |
|
138 | | - println!("\nUpdating versions..."); |
139 | | - run( |
140 | | - { |
141 | | - let mut cmd = Command::new("cargo"); |
142 | | - cmd.args(["script", "scripts/update_version.rs", "--", &target_version]); |
143 | | - cmd |
144 | | - }, |
145 | | - "Version update", |
146 | | - )?; |
| 133 | + ensure_clean_worktree()?; |
147 | 134 |
|
148 | 135 | let version = verify_versions_match()?; |
149 | | - println!("✓ All publishable crates are aligned at version {version}"); |
| 136 | + if let Some(expected_version) = args.get(1) { |
| 137 | + if expected_version != &version { |
| 138 | + return Err(format!( |
| 139 | + "Workspace is aligned at version {version}, expected {expected_version}" |
| 140 | + ) |
| 141 | + .into()); |
| 142 | + } |
| 143 | + } |
| 144 | + |
| 145 | + println!("Publishing aligned workspace version {version}"); |
150 | 146 | ensure_versions_are_unpublished(&version)?; |
151 | 147 | println!("✓ No publishable crate is already on crates.io at version {version}"); |
152 | 148 |
|
@@ -209,13 +205,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> { |
209 | 205 | } |
210 | 206 | } |
211 | 207 |
|
212 | | - println!( |
213 | | - "\nPublish readiness checks passed for version {version}. Type 'publish' to continue with actual publish:" |
214 | | - ); |
215 | | - let confirm = read_line_trimmed()?; |
216 | | - if confirm != "publish" { |
217 | | - return Err("Publish aborted by user".into()); |
218 | | - } |
| 208 | + println!("\nPublish readiness checks passed for version {version}."); |
219 | 209 |
|
220 | 210 | for (idx, crate_name) in PUBLISH_ORDER.iter().enumerate() { |
221 | 211 | println!("\nPublishing {crate_name}..."); |
|
0 commit comments