Skip to content

Commit

Permalink
chore: prepare release v0.4.2
Browse files Browse the repository at this point in the history
  • Loading branch information
zifeo committed Jun 5, 2023
1 parent d975582 commit f80655f
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 44 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
run: |
VERSION=$(cargo run -- --version | cut -d' ' -f2)
if [[ "${{ github.ref_name }}" != "v$VERSION" ]]; then
echo "Tag does not match code version, stopping."
echo "Tag does not match code version v$VERSION, stopping."
exit -1
fi
echo "Releasing v$VERSION"
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "whiz"
version = "0.4.2-beta.1"
version = "0.4.2"
edition = "2021"
description = "Modern DAG/tasks runner for multi-platform monorepos."
license = "MPL-2.0"
Expand Down
8 changes: 7 additions & 1 deletion src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,14 @@ pub enum Command {
}

#[derive(Parser, Debug)]
#[clap(author, version, about, long_about = None)]
#[clap(name="whiz", about, long_about = None, disable_version_flag = true, disable_help_flag = true)]
pub struct Args {
#[clap(long, value_parser)]
pub version: bool,

#[clap(short, long, value_parser)]
pub help: bool,

#[clap(subcommand)]
pub command: Option<Command>,

Expand Down
85 changes: 45 additions & 40 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use anyhow::anyhow;
use anyhow::Ok;
use anyhow::Result;
use chrono::{Duration, Utc};
use clap::CommandFactory;
use clap::Parser;
use self_update::{backends::github::Update, cargo_crate_version, update::UpdateStatus};
use tokio::time::{sleep, Duration as TokioDuration};
Expand Down Expand Up @@ -53,7 +54,46 @@ async fn upgrade_check() -> Result<()> {
Ok(())
}

fn main() {
fn main() -> Result<()> {
let args = Args::try_parse()?;

if args.version {
println!("whiz {}", env!("CARGO_PKG_VERSION"));
return Ok(());
}

if args.help {
Args::command().print_help()?;
return Ok(());
}

if let Some(Command::Upgrade(opts)) = args.command {
let mut update = Update::configure();
update
.repo_owner("zifeo")
.repo_name("whiz")
.bin_name("whiz")
.show_download_progress(true)
.current_version(cargo_crate_version!())
.no_confirm(opts.yes);

if let Some(version) = opts.version {
update.target_version_tag(&format!("v{version}"));
}

match update.build()?.update_extended()? {
UpdateStatus::UpToDate => println!("Already up to date!"),
UpdateStatus::Updated(release) => {
println!("Updated successfully to {}!", release.version);
println!(
"Release notes: https://github.com/zifeo/whiz/releases/tag/{}",
release.name
);
}
};
return Ok(());
};

let system = System::with_tokio_rt(|| {
tokio::runtime::Builder::new_multi_thread()
.worker_threads(2)
Expand All @@ -64,16 +104,18 @@ fn main() {
});

Arbiter::current().spawn(async {
run().await.unwrap_or_else(|e| {
run(args).await.unwrap_or_else(|e| {
eprintln!("{}", e);
System::current().stop_with_code(1);
})
});

let _ = system.run();

Ok(())
}

async fn run() -> Result<()> {
async fn run(args: Args) -> Result<()> {
#[cfg(target_os = "windows")]
std::env::set_var(
"PWD",
Expand All @@ -87,43 +129,6 @@ async fn run() -> Result<()> {
.await
.unwrap_or_else(|e| eprintln!("cannot check for update: {}", e));

let args = Args::try_parse()?;

if let Some(command) = args.command {
match command {
Command::Upgrade(opts) => {
tokio::task::spawn_blocking(move || {
let mut update = Update::configure();
update
.repo_owner("zifeo")
.repo_name("whiz")
.bin_name("whiz")
.show_download_progress(true)
.current_version(cargo_crate_version!())
.no_confirm(opts.yes);

if let Some(version) = opts.version {
update.target_version_tag(&format!("v{version}"));
}

match update.build()?.update_extended()? {
UpdateStatus::UpToDate => println!("Already up to date!"),
UpdateStatus::Updated(release) => {
println!("Updated successfully to {}!", release.version);
println!(
"Release notes: https://github.com/zifeo/whiz/releases/tag/{}",
release.name
);
}
};
Ok(())
})
.await??;
}
}
return Ok(());
};

let (config_file, config_path) =
recurse_config_file(&args.file).map_err(|err| anyhow!("file error: {}", err))?;

Expand Down

0 comments on commit f80655f

Please sign in to comment.