|
1 | 1 | mod api;
|
2 | 2 | mod cargo;
|
3 | 3 | mod exit_status_ext;
|
| 4 | +mod git; |
4 | 5 |
|
5 | 6 | #[macro_use]
|
6 | 7 | extern crate tracing;
|
@@ -52,27 +53,34 @@ async fn main() -> anyhow::Result<()> {
|
52 | 53 | let old_version = krate.max_version;
|
53 | 54 | let mut new_version = old_version.clone();
|
54 | 55 |
|
55 |
| - if options.skip_publish { |
56 |
| - info!("Skipping publish step"); |
57 |
| - } else { |
58 |
| - new_version.patch += 1; |
59 |
| - info!(%old_version, %new_version, "Calculated new version number"); |
| 56 | + new_version.patch += 1; |
| 57 | + info!(%old_version, %new_version, "Calculated new version number"); |
60 | 58 |
|
61 |
| - info!("Creating temporary working folder…"); |
62 |
| - let tempdir = tempdir().context("Failed to create temporary working folder")?; |
63 |
| - debug!(tempdir.path = %tempdir.path().display()); |
| 59 | + info!("Creating temporary working folder…"); |
| 60 | + let tempdir = tempdir().context("Failed to create temporary working folder")?; |
| 61 | + debug!(tempdir.path = %tempdir.path().display()); |
64 | 62 |
|
65 |
| - info!("Creating `{}` project…", options.crate_name); |
66 |
| - let project_path = create_project(tempdir.path(), &options.crate_name, &new_version) |
| 63 | + info!("Creating `{}` project…", options.crate_name); |
| 64 | + let project_path = create_project(tempdir.path(), &options.crate_name, &new_version) |
| 65 | + .await |
| 66 | + .context("Failed to create project")?; |
| 67 | + |
| 68 | + if options.skip_publish { |
| 69 | + info!("Packaging crate file…"); |
| 70 | + cargo::package(&project_path) |
67 | 71 | .await
|
68 |
| - .context("Failed to create project")?; |
| 72 | + .context("Failed to run `cargo package`")?; |
69 | 73 |
|
| 74 | + info!("Skipping publish step"); |
| 75 | + } else { |
70 | 76 | info!("Publishing to staging.crates.io…");
|
71 | 77 | cargo::publish(&project_path, &options.token)
|
72 | 78 | .await
|
73 | 79 | .context("Failed to run `cargo publish`")?;
|
74 | 80 | }
|
75 | 81 |
|
| 82 | + drop(tempdir); |
| 83 | + |
76 | 84 | let version = new_version;
|
77 | 85 | info!(%version, "Checking staging.crates.io API for the new version…");
|
78 | 86 |
|
@@ -217,5 +225,14 @@ description = "test crate"
|
217 | 225 | .context("Failed to write `README.md` file content")?;
|
218 | 226 | }
|
219 | 227 |
|
| 228 | + info!("Creating initial git commit…"); |
| 229 | + git::add_all(&project_path) |
| 230 | + .await |
| 231 | + .context("Failed to add initial changes to git")?; |
| 232 | + |
| 233 | + git::commit(&project_path, "initial commit") |
| 234 | + .await |
| 235 | + .context("Failed to commit initial changes")?; |
| 236 | + |
220 | 237 | Ok(project_path)
|
221 | 238 | }
|
0 commit comments