1
use std::error::Error;
2

            
3
use duct::cmd;
4

            
5
/// Runs `cargo publish --dry-run` for all crates to verify they can be published.
6
pub(crate) fn publish_crates() -> Result<(), Box<dyn Error>> {
7
    // The list of crates to publish, they must be published in order of dependencies, i.e., downstream first.
8
    let crates = [
9
        "merc_utilities",
10
        "merc_number",
11
        "merc_io",
12
        "merc_collections",
13
        "merc_unsafety",
14
        "merc_sharedmutex",
15
        "merc_macros",
16
        "merc_aterm",
17
        "merc_data",
18
        "merc_lts",
19
        "merc_reduction",
20
        "merc_refinement",
21
        "merc_syntax",
22
        "merc_sabre",
23
        "merc_ldd",
24
        "merc_symbolic",
25
        "merc_vpg",
26
    ];
27

            
28
    for library in &crates {
29
        // First do a dry run of the publish command to check that everything is fine.
30
        cmd!("cargo", "publish", "--dry-run", "-p", library)
31
            .run()
32
            .map_err(|err| format!("Failed to publish crate {library}: {err}"))?;
33
    }
34

            
35
    Ok(())
36
}