Desktop: Add commit info to binaries build with Nix (#3635)
This commit is contained in:
parent
39849c9c02
commit
6616d1bfb1
|
|
@ -109,13 +109,20 @@ deps.crane.lib.buildPackage (
|
|||
}
|
||||
else
|
||||
{ }
|
||||
);
|
||||
) // {
|
||||
GRAPHITE_GIT_COMMIT_HASH = inputs.self.rev or "unknown";
|
||||
GRAPHITE_GIT_COMMIT_DATE = inputs.self.lastModified or "unknown";
|
||||
};
|
||||
|
||||
postUnpack = ''
|
||||
mkdir ./branding
|
||||
cp -r ${branding}/* ./branding
|
||||
'';
|
||||
|
||||
preBuild = if inputs.self ? rev then ''
|
||||
export GRAPHITE_GIT_COMMIT_DATE="$(date -u -d "@$GRAPHITE_GIT_COMMIT_DATE" +"%Y-%m-%dT%H:%M:%SZ")"
|
||||
'' else "";
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out/bin
|
||||
cp target/${if dev then "debug" else "release"}/graphite $out/bin/graphite
|
||||
|
|
@ -125,6 +132,12 @@ deps.crane.lib.buildPackage (
|
|||
|
||||
mkdir -p $out/share/icons/hicolor/scalable/apps
|
||||
cp ${branding}/app-icons/graphite.svg $out/share/icons/hicolor/scalable/apps/art.graphite.Graphite.svg
|
||||
mkdir -p $out/share/icons/hicolor/512x512/apps
|
||||
cp ${branding}/app-icons/graphite-512.png $out/share/icons/hicolor/512x512/apps/art.graphite.Graphite.png
|
||||
mkdir -p $out/share/icons/hicolor/256x256/apps
|
||||
cp ${branding}/app-icons/graphite-256.png $out/share/icons/hicolor/256x256/apps/art.graphite.Graphite.png
|
||||
mkdir -p $out/share/icons/hicolor/128x128/apps
|
||||
cp ${branding}/app-icons/graphite-128.png $out/share/icons/hicolor/128x128/apps/art.graphite.Graphite.png
|
||||
'';
|
||||
|
||||
postFixup = ''
|
||||
|
|
|
|||
|
|
@ -18,16 +18,18 @@ fn main() {
|
|||
if !gh.trim().is_empty() {
|
||||
gh.trim().to_string()
|
||||
} else {
|
||||
git_or_unknown(&["rev-parse", "--abbrev-ref", "HEAD"])
|
||||
git(&["rev-parse", "--abbrev-ref", "HEAD"]).unwrap_or_default()
|
||||
}
|
||||
});
|
||||
|
||||
// Instruct Cargo to set environment variables for compile time.
|
||||
// They are accessed with the `env!("GRAPHITE_*")` macro in the codebase.
|
||||
println!("cargo:rustc-env=GRAPHITE_GIT_COMMIT_DATE={commit_date}");
|
||||
println!("cargo:rustc-env=GRAPHITE_GIT_COMMIT_HASH={commit_hash}");
|
||||
println!("cargo:rustc-env=GRAPHITE_GIT_COMMIT_BRANCH={commit_branch}");
|
||||
println!("cargo:rustc-env=GRAPHITE_RELEASE_SERIES={GRAPHITE_RELEASE_SERIES}");
|
||||
if !commit_branch.is_empty() {
|
||||
println!("cargo:rustc-env=GRAPHITE_GIT_COMMIT_BRANCH={commit_branch}");
|
||||
}
|
||||
println!("cargo:rustc-env=GRAPHITE_GIT_COMMIT_HASH={commit_hash}");
|
||||
println!("cargo:rustc-env=GRAPHITE_GIT_COMMIT_DATE={commit_date}");
|
||||
}
|
||||
|
||||
/// Get an environment variable, or if it is not set or empty, use the provided fallback function. Returns a string with trimmed whitespace.
|
||||
|
|
|
|||
|
|
@ -39,19 +39,17 @@ impl Default for Editor {
|
|||
}
|
||||
|
||||
pub const GRAPHITE_RELEASE_SERIES: &str = env!("GRAPHITE_RELEASE_SERIES");
|
||||
pub const GRAPHITE_GIT_COMMIT_DATE: &str = env!("GRAPHITE_GIT_COMMIT_DATE");
|
||||
pub const GRAPHITE_GIT_COMMIT_BRANCH: Option<&str> = option_env!("GRAPHITE_GIT_COMMIT_BRANCH");
|
||||
pub const GRAPHITE_GIT_COMMIT_HASH: &str = env!("GRAPHITE_GIT_COMMIT_HASH");
|
||||
pub const GRAPHITE_GIT_COMMIT_BRANCH: &str = env!("GRAPHITE_GIT_COMMIT_BRANCH");
|
||||
pub const GRAPHITE_GIT_COMMIT_DATE: &str = env!("GRAPHITE_GIT_COMMIT_DATE");
|
||||
|
||||
pub fn commit_info_localized(localized_commit_date: &str) -> String {
|
||||
format!(
|
||||
"Release Series: {}\n\
|
||||
Branch: {}\n\
|
||||
Commit: {}\n\
|
||||
{}",
|
||||
GRAPHITE_RELEASE_SERIES,
|
||||
GRAPHITE_GIT_COMMIT_BRANCH,
|
||||
GRAPHITE_GIT_COMMIT_HASH.get(..8).unwrap_or(GRAPHITE_GIT_COMMIT_HASH),
|
||||
localized_commit_date
|
||||
)
|
||||
let mut info = String::new();
|
||||
info.push_str(&format!("Release Series: {GRAPHITE_RELEASE_SERIES}\n"));
|
||||
if let Some(branch) = GRAPHITE_GIT_COMMIT_BRANCH {
|
||||
info.push_str(&format!("Branch: {branch}\n"));
|
||||
}
|
||||
info.push_str(&format!("Commit: {}\n", GRAPHITE_GIT_COMMIT_HASH.get(..8).unwrap_or(GRAPHITE_GIT_COMMIT_HASH)));
|
||||
info.push_str(localized_commit_date);
|
||||
info
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
use super::simple_dialogs::{self, AboutGraphiteDialog, DemoArtworkDialog, LicensesDialog};
|
||||
use crate::application::GRAPHITE_GIT_COMMIT_DATE;
|
||||
use crate::messages::dialog::simple_dialogs::LicensesThirdPartyDialog;
|
||||
use crate::messages::layout::utility_types::widget_prelude::*;
|
||||
use crate::messages::prelude::*;
|
||||
|
|
@ -48,7 +49,7 @@ impl MessageHandler<DialogMessage, DialogMessageContext<'_>> for DialogMessageHa
|
|||
}
|
||||
DialogMessage::RequestAboutGraphiteDialog => {
|
||||
responses.add(FrontendMessage::TriggerAboutGraphiteLocalizedCommitDate {
|
||||
commit_date: env!("GRAPHITE_GIT_COMMIT_DATE").into(),
|
||||
commit_date: GRAPHITE_GIT_COMMIT_DATE.into(),
|
||||
});
|
||||
}
|
||||
DialogMessage::RequestAboutGraphiteDialogWithLocalizedCommitDate {
|
||||
|
|
|
|||
|
|
@ -964,7 +964,7 @@ impl MessageHandler<PortfolioMessage, PortfolioMessageContext<'_>> for Portfolio
|
|||
}
|
||||
PortfolioMessage::RequestStatusBarInfoLayout => {
|
||||
#[cfg(not(target_family = "wasm"))]
|
||||
let widgets = vec![TextLabel::new("Graphite (beta) 1.0.0-RC2").disabled(true).widget_instance()];
|
||||
let widgets = vec![TextLabel::new("Graphite 1.0.0-RC2").disabled(true).widget_instance()];
|
||||
#[cfg(target_family = "wasm")]
|
||||
let widgets = vec![];
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue