Skip to content

Commit

Permalink
Verify that cargo xtask publish will work
Browse files Browse the repository at this point in the history
This change allows us to perform a `publish --dry-run` for each of the
crates to make sure this still works. Note that `cargo xtask publish
--dry-run` will use, by default, the `dynamic-linking` feature of
`openvino-sys` which requires an OpenVINO installation to compile
against.
  • Loading branch information
abrown committed May 12, 2022
1 parent e687811 commit 30d99b3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 14 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ jobs:
run: |
source /opt/intel/openvino_2022/setupvars.sh
cargo test --features openvino-sys/runtime-linking
- name: Verify publish
run: cargo xtask publish --dry-run

# Build and test from an existing OpenVINO installation inside a Docker image (i.e. download the
# binaries, then compile against these).
Expand Down
31 changes: 17 additions & 14 deletions crates/xtask/src/publish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,22 +42,25 @@ impl PublishCommand {
let crates_dir = path_to_crates()?;
for krate in PUBLICATION_ORDER {
println!("> publish {}", krate);
if !self.dry_run {
let krate_dir = crates_dir.clone().join(krate);
let exec_result = exec(
Command::new("cargo")
.arg("publish")
.arg("--no-verify")
.current_dir(&krate_dir),
);
let krate_dir = crates_dir.clone().join(krate);
let mut command = Command::new("cargo");
command.current_dir(&krate_dir).arg("publish");
if self.dry_run {
command.arg("--dry-run");
} else {
command.arg("--no-verify");
}

// We want to continue even if a crate does not publish: this allows us to re-run
// the `publish` command if uploading one or more crates fails.
if let Err(e) = exec_result {
println!("Failed to publish crate {}, continuing:\n {}", krate, e);
}
let exec_result = exec(&mut command);

// Hopefully this gives crates.io enough time for subsequent publications to work.
// We want to continue even if a crate does not publish: this allows us to re-run
// the `publish` command if uploading one or more crates fails.
if let Err(e) = exec_result {
println!("Failed to publish crate {}, continuing:\n {}", krate, e);
}

// Hopefully this gives crates.io enough time for subsequent publications to work.
if !self.dry_run {
sleep(Duration::from_secs(20));
}
}
Expand Down

0 comments on commit 30d99b3

Please sign in to comment.