feat: color and time release output
Rust CI Cargo tests passed.
Gitea/rust_realease/pipeline/head This commit looks good
Details
Rust CI Cargo tests passed.
Gitea/rust_realease/pipeline/head This commit looks good
Details
This commit is contained in:
parent
50acd7653f
commit
70a5db9f76
|
|
@ -185,6 +185,18 @@ version = "1.0.5"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1d07550c9036bf2ae0c684c4297d503f838287c83c53686d05370d0e139ae570"
|
||||
|
||||
[[package]]
|
||||
name = "console"
|
||||
version = "0.16.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e96a4956774c13c126a8b5af4daa79384f4d826534c95a02d76afb39e2ab64e3"
|
||||
dependencies = [
|
||||
"encode_unicode",
|
||||
"libc",
|
||||
"unicode-width",
|
||||
"windows-sys 0.61.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cpufeatures"
|
||||
version = "0.2.17"
|
||||
|
|
@ -264,6 +276,12 @@ dependencies = [
|
|||
"syn 3.0.5",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "encode_unicode"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "34aa73646ffb006b8f5147f3dc182bd4bcb190227ce861fc4a4844bf8e3cb2c0"
|
||||
|
||||
[[package]]
|
||||
name = "equivalent"
|
||||
version = "1.0.2"
|
||||
|
|
@ -973,9 +991,10 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "rust_realease"
|
||||
version = "0.1.2"
|
||||
version = "0.1.3"
|
||||
dependencies = [
|
||||
"clap",
|
||||
"console",
|
||||
"directories",
|
||||
"flate2",
|
||||
"regex",
|
||||
|
|
@ -1453,6 +1472,12 @@ version = "1.0.24"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-width"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b4ac048d71ede7ee76d585517add45da530660ef4390e49b098733c6e897f254"
|
||||
|
||||
[[package]]
|
||||
name = "untrusted"
|
||||
version = "0.9.0"
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "rust_realease"
|
||||
version = "0.1.2"
|
||||
version = "0.1.3"
|
||||
edition = "2021"
|
||||
publish = false
|
||||
repository = "https://proxy.dandaedre.com/gitea/idle-org/rust_realease"
|
||||
|
|
@ -12,6 +12,7 @@ bin-dir = "{ name }-{ target }-v{ version }/{ bin }{ binary-ext }"
|
|||
|
||||
[dependencies]
|
||||
clap = { version = "4.5", features = ["derive"] }
|
||||
console = "0.16"
|
||||
directories = "6.0"
|
||||
toml = "1.1"
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
|
|
|
|||
|
|
@ -37,6 +37,10 @@ rust_realease ./my-workspace --package my-tool --dry-run
|
|||
|
||||
Each run handles one package and all of its Cargo binary targets. A dry run reports the package, version, expected tag, metadata changes, build targets, artifact names, prerequisites, and release destination. It writes no project files, builds no binaries, and changes no Git refs or releases. It exits nonzero when it finds requirements that still need attention.
|
||||
|
||||
Interactive terminals use colored status markers. Cross builds report elapsed
|
||||
time for every target and for the complete build. Redirected output and CI logs
|
||||
remain plain.
|
||||
|
||||
## Prepare a release
|
||||
|
||||
Preview the project changes first:
|
||||
|
|
|
|||
13
src/build.rs
13
src/build.rs
|
|
@ -1,7 +1,8 @@
|
|||
use crate::{config::Config, error::Error, policy, project::SelectedPackage, runner::Runner};
|
||||
use crate::{config::Config, error::Error, policy, project::SelectedPackage, runner::Runner, ui};
|
||||
use std::{
|
||||
env, fs,
|
||||
path::{Path, PathBuf},
|
||||
time::Instant,
|
||||
};
|
||||
|
||||
#[derive(Debug)]
|
||||
|
|
@ -190,8 +191,10 @@ pub fn build(
|
|||
&config.profile
|
||||
};
|
||||
let mut outputs = Vec::new();
|
||||
let builds_started = Instant::now();
|
||||
for target in &config.targets {
|
||||
println!("Building {target}");
|
||||
let target_started = Instant::now();
|
||||
// Cross images can use different host libc versions. Keep their native
|
||||
// build scripts and proc macros isolated so a later image never tries
|
||||
// to execute artifacts produced by an earlier one.
|
||||
|
|
@ -223,7 +226,15 @@ pub fn build(
|
|||
target: target.clone(),
|
||||
binaries,
|
||||
});
|
||||
ui::success(format_args!(
|
||||
"Built {target} in {:.1}s",
|
||||
target_started.elapsed().as_secs_f64()
|
||||
));
|
||||
}
|
||||
ui::success(format_args!(
|
||||
"Cross builds complete in {:.1}s",
|
||||
builds_started.elapsed().as_secs_f64()
|
||||
));
|
||||
Ok(outputs)
|
||||
}
|
||||
|
||||
|
|
|
|||
43
src/cli.rs
43
src/cli.rs
|
|
@ -7,7 +7,7 @@ use crate::{
|
|||
model::Stage,
|
||||
policy, prepare, project,
|
||||
runner::Runner,
|
||||
verify,
|
||||
ui, verify,
|
||||
};
|
||||
use clap::Parser;
|
||||
use std::path::PathBuf;
|
||||
|
|
@ -134,11 +134,11 @@ pub fn run(mut args: Cli) -> Result<(), Error> {
|
|||
args.tag
|
||||
)));
|
||||
}
|
||||
println!("Package: {}", selected.name);
|
||||
println!("Version: {}", selected.version);
|
||||
println!("Binaries: {}", selected.binaries.join(", "));
|
||||
println!("Manifest: {}", selected.manifest.display());
|
||||
println!("Tag: {tag}");
|
||||
ui::detail("Package", &selected.name);
|
||||
ui::detail("Version", &selected.version);
|
||||
ui::detail("Binaries", selected.binaries.join(", "));
|
||||
ui::detail("Manifest", selected.manifest.display());
|
||||
ui::detail("Tag", &tag);
|
||||
if args
|
||||
.stop_after
|
||||
.is_some_and(|stage| stage.order() <= Stage::Inspect.order())
|
||||
|
|
@ -193,9 +193,9 @@ pub fn run(mut args: Cli) -> Result<(), Error> {
|
|||
)?;
|
||||
if issues.is_empty() {
|
||||
if config.package_format.archives() {
|
||||
println!("Binstall metadata: valid");
|
||||
ui::success("Binstall metadata valid");
|
||||
} else {
|
||||
println!("Release metadata: valid");
|
||||
ui::success("Release metadata valid");
|
||||
}
|
||||
}
|
||||
for issue in &issues {
|
||||
|
|
@ -262,7 +262,10 @@ pub fn run(mut args: Cli) -> Result<(), Error> {
|
|||
println!("Binstall {key}: {value}");
|
||||
}
|
||||
}
|
||||
println!("Release destination: {repository}/releases/tag/{tag}");
|
||||
ui::detail(
|
||||
"Release destination",
|
||||
format_args!("{repository}/releases/tag/{tag}"),
|
||||
);
|
||||
let needs_cross = args.stop_after != Some(Stage::Verify);
|
||||
let needs_binstall = config.package_format.archives()
|
||||
&& !args.skip_binstall_test
|
||||
|
|
@ -293,10 +296,10 @@ pub fn run(mut args: Cli) -> Result<(), Error> {
|
|||
}
|
||||
}
|
||||
for problem in &problems {
|
||||
println!("Prerequisite: {problem}");
|
||||
ui::warning(format_args!("Prerequisite: {problem}"));
|
||||
}
|
||||
if args.dry_run {
|
||||
println!("Dry run complete: no manifest edits, builds or release mutations.");
|
||||
ui::success("Dry run complete: no manifest edits, builds or release mutations");
|
||||
if !issues.is_empty() || !problems.is_empty() {
|
||||
return Err(Error(
|
||||
"Dry run found the metadata/prerequisite issues reported above.".into(),
|
||||
|
|
@ -325,15 +328,19 @@ pub fn run(mut args: Cli) -> Result<(), Error> {
|
|||
&outputs,
|
||||
config.package_format,
|
||||
)?;
|
||||
println!(
|
||||
"Artifacts: {}",
|
||||
ui::detail(
|
||||
"Artifacts",
|
||||
sums.parent().map_or_else(
|
||||
|| sums.display().to_string(),
|
||||
|path| path.display().to_string()
|
||||
)
|
||||
|path| path.display().to_string(),
|
||||
),
|
||||
);
|
||||
for artifact in &artifacts {
|
||||
println!("Packaged {}: {}", artifact.target, artifact.path.display());
|
||||
ui::success(format_args!(
|
||||
"Packaged {}: {}",
|
||||
artifact.target,
|
||||
artifact.path.display()
|
||||
));
|
||||
}
|
||||
if args.stop_after == Some(Stage::Package) {
|
||||
return Ok(());
|
||||
|
|
@ -342,7 +349,7 @@ pub fn run(mut args: Cli) -> Result<(), Error> {
|
|||
let (api, private) =
|
||||
publication.ok_or_else(|| Error("Publication client was not initialized.".into()))?;
|
||||
let release = api.ensure_release(&tag, &commit, args.draft, args.prerelease)?;
|
||||
println!("Release ready: {tag}");
|
||||
ui::success(format_args!("Release ready: {tag}"));
|
||||
if args.stop_after == Some(Stage::Release) {
|
||||
return Ok(());
|
||||
}
|
||||
|
|
@ -369,7 +376,7 @@ pub fn run(mut args: Cli) -> Result<(), Error> {
|
|||
if config.package_format.archives() && !args.skip_binstall_test {
|
||||
verify::verify_binstall(&checkout.root, &selected, &config.targets, &runner)?;
|
||||
}
|
||||
println!("Release completed and published artifacts verified.");
|
||||
ui::success("Release completed and published artifacts verified");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ mod policy;
|
|||
mod prepare;
|
||||
mod project;
|
||||
mod runner;
|
||||
mod ui;
|
||||
mod verify;
|
||||
|
||||
use clap::Parser;
|
||||
|
|
@ -19,7 +20,7 @@ use clap::Parser;
|
|||
fn main() {
|
||||
let args = cli::Cli::parse();
|
||||
if let Err(error) = cli::run(args) {
|
||||
eprintln!("error: {error}");
|
||||
ui::error(error);
|
||||
std::process::exit(1);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,19 @@
|
|||
use console::{style, Style};
|
||||
use std::fmt::Display;
|
||||
|
||||
pub fn detail(label: &str, value: impl Display) {
|
||||
println!("{}: {value}", style(label).cyan().bold());
|
||||
}
|
||||
|
||||
pub fn success(message: impl Display) {
|
||||
println!("{} {message}", style("✓").green().bold());
|
||||
}
|
||||
|
||||
pub fn warning(message: impl Display) {
|
||||
println!("{} {message}", style("!").yellow().bold());
|
||||
}
|
||||
|
||||
pub fn error(message: impl Display) {
|
||||
let marker = Style::new().red().bold().for_stderr().apply_to("error:");
|
||||
eprintln!("{marker} {message}");
|
||||
}
|
||||
|
|
@ -42,7 +42,7 @@ fn release_wrapper_passes_the_token_and_preserves_the_ssh_origin() {
|
|||
}
|
||||
fs::write(
|
||||
repository.join("Cargo.toml"),
|
||||
"[package]\nname = \"rust_realease\"\nversion = \"0.1.2\"\n",
|
||||
"[package]\nname = \"rust_realease\"\nversion = \"0.1.3\"\n",
|
||||
)
|
||||
.expect("manifest should be written");
|
||||
fs::write(repository.join("token.txt"), "test-token\n").expect("token file should be written");
|
||||
|
|
|
|||
Loading…
Reference in New Issue