Added build script env var exports
This commit is contained in:
parent
4c5c73e670
commit
c58b553e73
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -1563,7 +1563,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "shibe-bot"
|
||||
version = "0.4.0"
|
||||
version = "0.4.1"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"dotenvy",
|
||||
|
@ -3,7 +3,7 @@ name = "shibe-bot"
|
||||
description = "A Discord bot written in Rust, using Poise."
|
||||
license = "MIT"
|
||||
readme = "README.md"
|
||||
version = "0.4.0"
|
||||
version = "0.4.1"
|
||||
edition = "2021"
|
||||
build = "build.rs"
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
# Shibe Bot 0.4.0
|
||||
# Shibe Bot 0.4.1
|
||||
|
||||
[](https://github.com/shibedrill/shibe-bot/actions/workflows/rust.yml)
|
||||
[](LICENSE.txt)
|
||||
|
48
build.rs
48
build.rs
@ -11,5 +11,53 @@ fn main() -> Result<(), Error> {
|
||||
.add_instructions(&cargo)?
|
||||
.add_instructions(&rustc)?
|
||||
.emit()?;
|
||||
|
||||
let git_commit_id = std::process::Command::new("git")
|
||||
.arg("rev-parse")
|
||||
.arg("--short")
|
||||
.arg("HEAD")
|
||||
.output()?;
|
||||
let git_commit_date = std::process::Command::new("git")
|
||||
.arg("show")
|
||||
.arg("-s")
|
||||
.arg("--format=%ci")
|
||||
.output()?;
|
||||
let git_commit_message = std::process::Command::new("git")
|
||||
.arg("show")
|
||||
.arg("-s")
|
||||
.arg("--format=%s")
|
||||
.output()?;
|
||||
let git_commit_author_name = std::process::Command::new("git")
|
||||
.arg("show")
|
||||
.arg("-s")
|
||||
.arg("--format=%an")
|
||||
.output()?;
|
||||
let git_commit_author_email = std::process::Command::new("git")
|
||||
.arg("show")
|
||||
.arg("-s")
|
||||
.arg("--format=%ae")
|
||||
.output()?;
|
||||
|
||||
println!(
|
||||
"cargo:rustc-env=GIT_COMMIT_ID={}",
|
||||
String::from_utf8(git_commit_id.stdout)?
|
||||
);
|
||||
println!(
|
||||
"cargo:rustc-env=GIT_COMMIT_DATE={}",
|
||||
String::from_utf8(git_commit_date.stdout)?
|
||||
);
|
||||
println!(
|
||||
"cargo:rustc-env=GIT_COMMIT_MSG={}",
|
||||
String::from_utf8(git_commit_message.stdout)?
|
||||
);
|
||||
println!(
|
||||
"cargo:rustc-env=GIT_COMMIT_AUTHOR_NAME={}",
|
||||
String::from_utf8(git_commit_author_name.stdout)?
|
||||
);
|
||||
println!(
|
||||
"cargo:rustc-env=GIT_COMMIT_AUTHOR_EMAIL={}",
|
||||
String::from_utf8(git_commit_author_email.stdout)?
|
||||
);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
@ -5,13 +5,23 @@ use crate::Error;
|
||||
#[poise::command(slash_command)]
|
||||
pub async fn version(ctx: Context<'_>) -> Result<(), Error> {
|
||||
ctx.say(format!(
|
||||
"Bot version: {}\n\
|
||||
"Source:\n\
|
||||
\tPackage version: {}\n\
|
||||
\tCommit ID: {}\n\
|
||||
\tCommit date: {}\n\
|
||||
\tCommit author: {} ({})\n\
|
||||
\tCommit message: {}\n\
|
||||
Build:\n\
|
||||
\tBuild date: {}\n\
|
||||
\tBuild timestamp: {}\n\
|
||||
\tTarget triple: {}\n\
|
||||
\trustc version: {}\n",
|
||||
env!("CARGO_PKG_VERSION"),
|
||||
env!("GIT_COMMIT_ID"),
|
||||
env!("GIT_COMMIT_DATE"),
|
||||
env!("GIT_COMMIT_AUTHOR_NAME"),
|
||||
env!("GIT_COMMIT_AUTHOR_EMAIL"),
|
||||
env!("GIT_COMMIT_MSG"),
|
||||
env!("VERGEN_BUILD_DATE"),
|
||||
env!("VERGEN_BUILD_TIMESTAMP"),
|
||||
env!("VERGEN_CARGO_TARGET_TRIPLE"),
|
||||
|
@ -119,7 +119,10 @@ async fn main() {
|
||||
// Build client
|
||||
let mut client = serenity::ClientBuilder::new(token, intents)
|
||||
.framework(framework)
|
||||
.activity(ActivityData::custom(format!("Version {}!", env!("CARGO_PKG_VERSION"))))
|
||||
.activity(ActivityData::custom(format!(
|
||||
"Version {}!",
|
||||
env!("CARGO_PKG_VERSION")
|
||||
)))
|
||||
.await
|
||||
.unwrap_or_else(|e| {
|
||||
error!("Building client failed: {}", e);
|
||||
|
Loading…
Reference in New Issue
Block a user