diff --git a/Earthfile b/Earthfile index d51c98a..b83a3e3 100644 --- a/Earthfile +++ b/Earthfile @@ -58,16 +58,7 @@ build-scripts: chmod +x "scripts/${script}" END - DO --pass-args +LABELS - - ARG EARTHLY_GIT_HASH - SAVE IMAGE --push "$IMAGE:$EARTHLY_GIT_HASH-build-scripts" - - ARG TAGGED="false" - ARG LATEST="false" - IF [ "$TAGGED" = "true" ] && [ "$LATEST" ] - SAVE IMAGE --push "$IMAGE:latest-build-scripts" - END + DO --pass-args +SAVE_IMAGE --SUFFIX="-build-scripts" blue-build-cli: ARG BASE_IMAGE="registry.fedoraproject.org/fedora-toolbox" @@ -151,7 +142,7 @@ version: COPY --keep-ts --dir src/ template/ recipe/ utils/ /app COPY --keep-ts Cargo.* /app - RUN echo "$(cargo metadata --format-version 1 | jq -r '.packages[] | select(.name == "blue-build") .version')" > /version + RUN echo "$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[] | select(.name == "blue-build") .version')" > /version SAVE ARTIFACT /version @@ -181,6 +172,8 @@ SAVE_IMAGE: ARG EARTHLY_GIT_BRANCH SAVE IMAGE --push "${IMAGE}:${EARTHLY_GIT_BRANCH}${SUFFIX}" END + ARG EARTHLY_GIT_HASH + SAVE IMAGE --push "${IMAGE}:${EARTHLY_GIT_HASH}${SUFFIX}" LABELS: FUNCTION diff --git a/src/commands/bug_report.rs b/src/commands/bug_report.rs index 8f29a53..ad25900 100644 --- a/src/commands/bug_report.rs +++ b/src/commands/bug_report.rs @@ -114,18 +114,12 @@ impl BugReportCommand { } fn get_recipe(&self) -> Option { - let recipe_path = self.recipe_path.clone().map_or_else( - || { - get_config_file("recipe", "Enter path to recipe file").map_or_else( - |_| { - trace!("Failed to get recipe"); - String::new() - }, - |recipe| recipe, - ) - }, - |recipe_path| recipe_path, - ); + let recipe_path = self.recipe_path.clone().unwrap_or_else(|| { + get_config_file("recipe", "Enter path to recipe file").unwrap_or_else(|_| { + trace!("Failed to get recipe"); + String::new() + }) + }); Recipe::parse(&recipe_path).ok() } diff --git a/src/commands/template.rs b/src/commands/template.rs index 3d1ef20..f3f71ac 100644 --- a/src/commands/template.rs +++ b/src/commands/template.rs @@ -13,7 +13,7 @@ use blue_build_utils::{ }, syntax_highlighting::{self, DefaultThemes}, }; -use clap::Args; +use clap::{crate_version, Args}; use log::{debug, info, trace, warn}; use typed_builder::TypedBuilder; @@ -120,9 +120,12 @@ impl TemplateCommand { .recipe_path(recipe_path.as_path()) .registry(self.get_registry()) .exports_tag(if shadow::COMMIT_HASH.is_empty() { - "latest" + // This is done for users who install via + // cargo. Cargo installs do not carry git + // information via shadow + format!("v{}", crate_version!()) } else { - shadow::COMMIT_HASH + shadow::COMMIT_HASH.to_string() }) .build(); diff --git a/src/drivers/opts/build.rs b/src/drivers/opts/build.rs index f840259..a8e3772 100644 --- a/src/drivers/opts/build.rs +++ b/src/drivers/opts/build.rs @@ -37,7 +37,7 @@ pub struct PushOpts<'a> { pub struct BuildTagPushOpts<'a> { /// The base image name. /// - /// NOTE: You cannot have this set with archive_path set. + /// NOTE: You cannot have this set with `archive-path` set. #[builder(default, setter(into, strip_option))] pub image: Option>,