Add commit hash for versioning
Some checks failed
Build and push container image / build (push) Has been cancelled
Some checks failed
Build and push container image / build (push) Has been cancelled
This commit is contained in:
parent
e519407557
commit
b54db60ce4
@ -36,6 +36,7 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
platforms: linux/amd64
|
platforms: linux/amd64
|
||||||
|
args: GIT_HASH=${{ env.GITHUB_SHA }}
|
||||||
push: true
|
push: true
|
||||||
tags: git.toast-server.net/toast/kon:main
|
tags: git.toast-server.net/toast/kon:main
|
||||||
build-args: CARGO_TOKEN=${{ secrets.CARGO_TOKEN }}
|
build-args: CARGO_TOKEN=${{ secrets.CARGO_TOKEN }}
|
||||||
|
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -1020,7 +1020,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "kon"
|
name = "kon"
|
||||||
version = "0.3.11"
|
version = "0.3.12"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bb8",
|
"bb8",
|
||||||
"bb8-postgres",
|
"bb8-postgres",
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "kon"
|
name = "kon"
|
||||||
version = "0.3.11"
|
version = "0.3.12"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
FROM rust:1.80-alpine3.20 AS chef
|
FROM rust:1.80-alpine3.20 AS chef
|
||||||
ENV RUSTFLAGS="-C target-feature=-crt-static"
|
ENV RUSTFLAGS="-C target-feature=-crt-static"
|
||||||
|
ARG GIT_HASH
|
||||||
|
ENV GIT_COMMIT_HASH=${GIT_HASH}
|
||||||
RUN apk add --no-cache openssl-dev musl-dev
|
RUN apk add --no-cache openssl-dev musl-dev
|
||||||
RUN cargo install cargo-chef
|
RUN cargo install cargo-chef
|
||||||
WORKDIR /builder
|
WORKDIR /builder
|
||||||
|
10
build.rs
Normal file
10
build.rs
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
fn main() {
|
||||||
|
#[cfg(feature = "production")]
|
||||||
|
{
|
||||||
|
if let Ok(git_commit_hash) = std::env::var("GIT_COMMIT_HASH") {
|
||||||
|
println!("cargo:rustc-env=GIT_COMMIT_HASH={}", &git_commit_hash[..7]);
|
||||||
|
} else {
|
||||||
|
println!("cargo:rustc-env=GIT_COMMIT_HASH=no_env_set");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,9 +1,10 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
Error,
|
Error,
|
||||||
|
GIT_COMMIT_HASH,
|
||||||
internals::utils::{
|
internals::utils::{
|
||||||
|
BOT_VERSION,
|
||||||
format_duration,
|
format_duration,
|
||||||
concat_message,
|
concat_message
|
||||||
BOT_VERSION
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -69,7 +70,7 @@ pub async fn uptime(ctx: poise::Context<'_, (), Error>) -> Result<(), Error> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let stat_msg = vec![
|
let stat_msg = vec![
|
||||||
format!("**{} {}**", _bot.name, BOT_VERSION.as_str()),
|
format!("**{} {}** `{}`", _bot.name, BOT_VERSION.as_str(), GIT_COMMIT_HASH),
|
||||||
format!(">>> System: `{}`", format_duration(sys_uptime)),
|
format!(">>> System: `{}`", format_duration(sys_uptime)),
|
||||||
format!("Process: `{}`", format_duration(proc_uptime)),
|
format!("Process: `{}`", format_duration(proc_uptime)),
|
||||||
format!("CPU: `{}`", format!("{}", cpu[0].brand())),
|
format!("CPU: `{}`", format!("{}", cpu[0].brand())),
|
||||||
|
@ -7,6 +7,7 @@ mod internals;
|
|||||||
use crate::{
|
use crate::{
|
||||||
internals::{
|
internals::{
|
||||||
utils::{
|
utils::{
|
||||||
|
BOT_VERSION,
|
||||||
token_path,
|
token_path,
|
||||||
mention_dev
|
mention_dev
|
||||||
},
|
},
|
||||||
@ -43,6 +44,10 @@ use poise::serenity_prelude::{
|
|||||||
type Error = Box<dyn std::error::Error + Send + Sync>;
|
type Error = Box<dyn std::error::Error + Send + Sync>;
|
||||||
static TASK_RUNNING: AtomicBool = AtomicBool::new(false);
|
static TASK_RUNNING: AtomicBool = AtomicBool::new(false);
|
||||||
|
|
||||||
|
#[cfg(feature = "production")]
|
||||||
|
pub static GIT_COMMIT_HASH: &str = env!("GIT_COMMIT_HASH");
|
||||||
|
pub static GIT_COMMIT_HASH: &str = "devel";
|
||||||
|
|
||||||
async fn on_ready(
|
async fn on_ready(
|
||||||
ctx: &Context,
|
ctx: &Context,
|
||||||
ready: &Ready,
|
ready: &Ready,
|
||||||
@ -56,6 +61,7 @@ async fn on_ready(
|
|||||||
println!("Event[Ready][Notice]: Session limit: {}/{}", session.remaining, session.total);
|
println!("Event[Ready][Notice]: Session limit: {}/{}", session.remaining, session.total);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
println!("Event[Ready]: Build version: {} ({})", BOT_VERSION.to_string(), GIT_COMMIT_HASH);
|
||||||
println!("Event[Ready]: Connected to API as {}", ready.user.name);
|
println!("Event[Ready]: Connected to API as {}", ready.user.name);
|
||||||
|
|
||||||
let message = CreateMessage::new();
|
let message = CreateMessage::new();
|
||||||
@ -173,7 +179,7 @@ async fn main() {
|
|||||||
Some(guild) => guild.name.clone(),
|
Some(guild) => guild.name.clone(),
|
||||||
None => String::from("Direct Message")
|
None => String::from("Direct Message")
|
||||||
};
|
};
|
||||||
println!("Discord[{}] {} ran /{}", get_guild_name, ctx.author().name, ctx.command().qualified_name);
|
println!("Discord[{}]: {} ran /{}", get_guild_name, ctx.author().name, ctx.command().qualified_name);
|
||||||
}),
|
}),
|
||||||
on_error: |error| Box::pin(async move {
|
on_error: |error| Box::pin(async move {
|
||||||
match error {
|
match error {
|
||||||
|
Loading…
Reference in New Issue
Block a user