feat: with vx.x.x
This commit is contained in:
41
src/main.rs
41
src/main.rs
@@ -1,19 +1,20 @@
|
||||
mod bump;
|
||||
mod conventional_commits;
|
||||
mod gitea;
|
||||
mod semantic;
|
||||
mod validate_pr;
|
||||
|
||||
use clap::Command;
|
||||
use tracing_subscriber::EnvFilter;
|
||||
use tracing_subscriber::{filter::LevelFilter, EnvFilter};
|
||||
|
||||
const VERSION: &'static str = "<dev>";
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> eyre::Result<()> {
|
||||
dotenv::dotenv().unwrap();
|
||||
color_eyre::install().unwrap();
|
||||
|
||||
tracing_subscriber::fmt()
|
||||
.pretty()
|
||||
.with_env_filter(EnvFilter::from_default_env())
|
||||
.with_env_filter(EnvFilter::default().add_directive(LevelFilter::INFO.into()))
|
||||
.init();
|
||||
|
||||
let matches = clap::Command::new("releaser")
|
||||
@@ -24,12 +25,44 @@ async fn main() -> eyre::Result<()> {
|
||||
.subcommand(
|
||||
Command::new("validate").about("Validate the semantic versioning of the software"),
|
||||
)
|
||||
.subcommand(
|
||||
Command::new("validate:pr")
|
||||
.about("Validate the semantic versioning of the software")
|
||||
.arg(clap::Arg::new("owner").long("owner").required(true))
|
||||
.arg(clap::Arg::new("repo").long("repo").required(true))
|
||||
.arg(
|
||||
clap::Arg::new("pull_request_id")
|
||||
.long("pull-request-id")
|
||||
.required(true)
|
||||
.value_parser(clap::value_parser!(u32).range(0..)),
|
||||
)
|
||||
.arg(
|
||||
clap::Arg::new("current_version")
|
||||
.long("current-version")
|
||||
.required(true),
|
||||
),
|
||||
)
|
||||
.subcommand(Command::new("bump").about("Bump the semantic versioning in git tags"))
|
||||
.get_matches();
|
||||
|
||||
match matches.subcommand() {
|
||||
Some(("release", sub_matches)) => {}
|
||||
Some(("validate", sub_matches)) => {}
|
||||
Some(("validate:pr", sub_matches)) => {
|
||||
let owner = sub_matches.get_one::<String>("owner").unwrap();
|
||||
let repo = sub_matches.get_one::<String>("repo").unwrap();
|
||||
let pull_request_id = sub_matches.get_one::<u32>("pull_request_id").unwrap();
|
||||
let current_version = sub_matches.get_one::<String>("current_version").unwrap();
|
||||
|
||||
match validate_pr::validate_pr(&owner, &repo, *pull_request_id, ¤t_version)
|
||||
.await?
|
||||
{
|
||||
Some(version) => {
|
||||
tracing::info!(version = version, "bumping version")
|
||||
}
|
||||
None => tracing::info!(version = current_version, "no version bump required!"),
|
||||
}
|
||||
}
|
||||
Some(("bump", sub_matches)) => {}
|
||||
_ => unreachable!(),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user