diff options
Diffstat (limited to 'xtask')
-rw-r--r-- | xtask/src/release.rs | 65 |
1 files changed, 24 insertions, 41 deletions
diff --git a/xtask/src/release.rs b/xtask/src/release.rs index 274df12..3e8f02e 100644 --- a/xtask/src/release.rs +++ b/xtask/src/release.rs @@ -10,65 +10,44 @@ use self::bump::{Bump, Level}; mod bump; -#[derive(Debug, Clone, Args)] -pub struct Release { - #[command(subcommand)] - step: Option<Step>, - - /// Level of version bump version. - #[arg(global = true, required = false)] - level: bump::Level, - - /// Options passed to git commit. - #[arg(global = true, last = true)] - git_commit_args: Vec<String>, -} - -impl Release { - pub fn run(self) -> Result<()> { - match self.step { - Some(step) => step.run(), - None => { - let bump = Step::bump(self.level)?; - - println!("Bumped version: {bump}"); - - Ok(()) - } - } - } -} - #[derive(Debug, Clone, Subcommand)] pub enum Step { /// Bump version in package files and commit changes. Bump { - #[arg(from_global)] + /// Level of version bump version. + #[arg(required = false)] level: bump::Level, }, /// Make a release commit. Commit { - #[arg(from_global)] + /// Options passed to git commit. + #[arg(last = true)] git_commit_args: Vec<String>, }, /// Create git tag for release. - Tag { - #[arg(from_global)] - level: bump::Level, - }, + Tag, +} + +#[derive(Debug, Clone, Args)] +pub struct Release { + #[command(subcommand)] + step: Step, } -impl Step { +impl Release { pub fn run(self) -> Result<()> { - match self { + match self.step { Step::Bump { level } => { let bump = Self::bump(level)?; println!("Bumped version: {bump}"); } - Step::Commit { git_commit_args } => Self::commit(git_commit_args)?, - Step::Tag { level } => { + Step::Commit { git_commit_args } => { + let version = PKG_VER.parse()?; + Self::commit(version, git_commit_args)? + } + Step::Tag => { let stdout = Command::new("git") .arg("describe") .arg("--abbrev=0") @@ -76,9 +55,11 @@ impl Step { .stdout; let prev = std::str::from_utf8(&stdout)? + .trim() .trim_start_matches('v') .parse()?; - let next = level.bump(&prev); + + let next = PKG_VER.parse()?; Self::tag(prev, next)?; } }; @@ -114,9 +95,11 @@ impl Step { Ok(bump) } - pub fn commit(git_commit_args: Vec<String>) -> Result<()> { + pub fn commit(version: Version, git_commit_args: Vec<String>) -> Result<()> { let git_commit = Command::new("git") .arg("commit") + .arg("-em") + .arg(format!("chore: release projectr version {version}")) .args(git_commit_args) .status()?; |