-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmain.rs
64 lines (54 loc) · 1.41 KB
/
main.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
use std::env;
use xaction::{cargo_toml, cmd, git, section, Result};
fn main() {
if let Err(err) = try_main() {
eprintln!("error: {}", err);
std::process::exit(1)
}
}
fn try_main() -> Result<()> {
let subcommand = std::env::args().nth(1);
match subcommand {
Some(it) if it == "ci" => (),
_ => {
print_usage();
Err("invalid arguments")?
}
}
let cargo_toml = cargo_toml()?;
{
let _s = section("TEST");
for &release in &[None, Some("--release")] {
for &tracing in &[&[][..], &["--features", "tracing"]] {
for &force in &[&[][..], &["--features", "force"]] {
cmd!(
"cargo test {release...} {tracing...} {force...}
--workspace -- --nocapture"
)
.run()?;
}
}
}
}
let version = cargo_toml.version()?;
let tag = format!("v{}", version);
let dry_run =
env::var("CI").is_err() || git::has_tag(&tag)? || git::current_branch()? != "master";
xaction::set_dry_run(dry_run);
{
let _s = section("PUBLISH");
cargo_toml.publish()?;
git::tag(&tag)?;
git::push_tags()?;
}
Ok(())
}
fn print_usage() {
eprintln!(
"\
Usage: cargo run -p xtask <SUBCOMMAND>
SUBCOMMANDS:
ci
"
)
}