Skip to content

Commit

Permalink
Release 0.16.3
Browse files Browse the repository at this point in the history
axum_garde@0.16.3
garde@0.16.3
garde_derive@0.16.3

Generated by cargo-workspaces
  • Loading branch information
jprochazk committed Nov 26, 2023
1 parent 8b1955e commit f0d066a
Show file tree
Hide file tree
Showing 8 changed files with 80 additions and 8 deletions.
2 changes: 1 addition & 1 deletion garde/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "garde"
version = "0.16.2"
version = "0.16.3"
edition = "2021"
repository = "https://github.com/jprochazk/garde"
license = "MIT OR Apache-2.0"
Expand Down
2 changes: 1 addition & 1 deletion garde_derive/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "garde_derive"
version = "0.16.2"
version = "0.16.3"
edition = "2021"
repository = "https://github.com/jprochazk/garde"
license = "MIT OR Apache-2.0"
Expand Down
2 changes: 1 addition & 1 deletion integrations/axum_garde/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "axum_garde"
version = "0.16.2"
version = "0.16.3"
edition = "2021"
repository = "https://github.com/jprochazk/garde"
license = "MIT OR Apache-2.0"
Expand Down
3 changes: 2 additions & 1 deletion xtask/src/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub enum Task {
Test(test::Test),
Check(check::Check),
Setup(setup::Setup),
// Version(Version),
Version(version::Version),
// Release(Release),
}

Expand All @@ -24,6 +24,7 @@ impl Task {
Task::Test(cmd) => cmd.run(),
Task::Check(cmd) => cmd.run(),
Task::Setup(cmd) => cmd.run(),
Task::Version(cmd) => cmd.run(),
}
}
}
2 changes: 2 additions & 0 deletions xtask/src/task/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ const TOOLS: &[&str] = &[
"cargo-udeps",
"cargo-pants",
"cargo-insta",
"cargo-semver-checks",
"cargo-workspaces",
"wasm-bindgen-cli",
];

Expand Down
6 changes: 3 additions & 3 deletions xtask/src/task/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ impl argp::FromArgValue for Target {
];

options
.iter()
.find(|(name, _)| value.eq_ignore_ascii_case(std::ffi::OsStr::new(*name)))
.map(|(_, target)| *target)
.into_iter()
.find(|(name, _)| value.eq_ignore_ascii_case(std::ffi::OsStr::new(name)))
.map(|(_, target)| target)
.ok_or_else(|| "invalid target, expected one of: unit, doc, ui, rules, axum".into())
}
}
Expand Down
49 changes: 48 additions & 1 deletion xtask/src/task/version.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,60 @@
use argp::FromArgs;

use crate::util::{cargo, CommandExt};
use crate::Result;

#[derive(FromArgs)]
#[argp(subcommand, name = "version", description = "Bump crate versions")]
pub struct Version {}
pub struct Version {
#[argp(positional, description = "one of: major, minor, patch")]
bump: Bump,
}

enum Bump {
Patch,
Minor,
Major,
}

impl Bump {
fn as_str(&self) -> &'static str {
match self {
Bump::Patch => "patch",
Bump::Minor => "minor",
Bump::Major => "major",
}
}
}

impl argp::FromArgValue for Bump {
fn from_arg_value(value: &std::ffi::OsStr) -> std::result::Result<Self, String> {
let options = [
("patch", Bump::Patch),
("minor", Bump::Minor),
("major", Bump::Major),
];

options
.into_iter()
.find(|(name, _)| value.eq_ignore_ascii_case(name))
.map(|(_, bump)| bump)
.ok_or_else(|| "invalid bump kind, expected one of: major, minor, patch".into())
}
}

impl Version {
pub fn run(self) -> Result {
// TODO: manually parse workspace and bump versions
cargo("workspaces")
.with_arg("version")
.with_arg(self.bump.as_str())
.with_args(["--force", "*"])
.run_async()?;

cargo("semver-checks")
.with_arg("--all-features")
.run_async()?;

Ok(())
}
}
22 changes: 22 additions & 0 deletions xtask/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ pub trait CommandExt {
K: AsRef<OsStr>,
V: AsRef<OsStr>;

fn run_async(self) -> Result;

fn run(self) -> Result;

fn run_with_output(self) -> Result<String>;
Expand Down Expand Up @@ -75,6 +77,10 @@ impl CommandExt for Command {
self
}

fn run_async(mut self) -> Result {
self.spawn()?.wait_async()
}

fn run(mut self) -> Result {
self.spawn()?.wait()?.check()
}
Expand Down Expand Up @@ -111,3 +117,19 @@ impl CheckStatus for std::process::Output {
self.status.check()
}
}

pub trait WaitAsync {
/// Wait with inherited IO
fn wait_async(self) -> Result;
}

impl WaitAsync for std::process::Child {
fn wait_async(mut self) -> Result {
loop {
if let Some(status) = self.try_wait()? {
status.check()?;
return Ok(());
}
}
}
}

0 comments on commit f0d066a

Please sign in to comment.