chore: Ensure cargo installs use version for build scripts image

This commit is contained in:
Gerald Pinder 2024-05-07 20:16:22 -04:00
parent 55c1b087f7
commit 2923c417ab
4 changed files with 17 additions and 27 deletions

View file

@ -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

View file

@ -114,18 +114,12 @@ impl BugReportCommand {
}
fn get_recipe(&self) -> Option<Recipe> {
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()
}

View file

@ -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();

View file

@ -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<Cow<'a, str>>,