diff --git a/crates/api_mastodon/src/entities/instance.rs b/crates/api_mastodon/src/entities/instance.rs index c8a4aebb..374284ce 100644 --- a/crates/api_mastodon/src/entities/instance.rs +++ b/crates/api_mastodon/src/entities/instance.rs @@ -1,5 +1,5 @@ use activitypub_federation::config::Data; -use hatsu_utils::{AppData, AppError}; +use hatsu_utils::{AppData, AppError, VERSION}; use serde::{Deserialize, Serialize}; use serde_json::{json, Value}; use url::Url; @@ -33,13 +33,13 @@ impl Instance { .hatsu_node_name .clone() .unwrap_or_else(|| String::from("Hatsu")), - version: String::from(env!("CARGO_PKG_VERSION")), + version: String::from(VERSION), source_url: Url::parse("https://github.com/importantimport/hatsu")?, description: data .env .hatsu_node_description .clone() - .unwrap_or_else(|| String::from(env!("CARGO_PKG_DESCRIPTION"))), + .unwrap_or_else(|| String::from(VERSION)), usage: json!({ "users": { "active_month": 0 diff --git a/crates/nodeinfo/src/schema.rs b/crates/nodeinfo/src/schema.rs index 7cfc23cf..ea03df7f 100644 --- a/crates/nodeinfo/src/schema.rs +++ b/crates/nodeinfo/src/schema.rs @@ -4,7 +4,7 @@ use hatsu_db_schema::{ prelude::{Post, User}, user, }; -use hatsu_utils::{AppData, AppError}; +use hatsu_utils::{AppData, AppError, VERSION}; use sea_orm::{ColumnTrait, EntityTrait, PaginatorTrait, QueryFilter}; use serde::{Deserialize, Serialize}; use utoipa::ToSchema; @@ -30,7 +30,7 @@ impl NodeInfo { version: String::from("2.0"), software: NodeInfoSoftware { name: String::from("hatsu"), - version: String::from(env!("CARGO_PKG_VERSION")), + version: String::from(VERSION), repository: None, homepage: None, }, @@ -47,7 +47,7 @@ impl NodeInfo { version: String::from("2.1"), software: NodeInfoSoftware { name: String::from("hatsu"), - version: String::from(env!("CARGO_PKG_VERSION")), + version: String::from(VERSION), repository: Some(String::from(env!("CARGO_PKG_REPOSITORY"))), homepage: Some(String::from(env!("CARGO_PKG_HOMEPAGE"))), }, diff --git a/crates/utils/src/data.rs b/crates/utils/src/data.rs index c91ec0b2..c8f8bcf5 100644 --- a/crates/utils/src/data.rs +++ b/crates/utils/src/data.rs @@ -2,7 +2,7 @@ use std::env; use sea_orm::DatabaseConnection; -use crate::AppError; +use crate::{AppError, VERSION}; #[derive(Clone, Debug)] pub struct AppData { @@ -41,7 +41,7 @@ impl AppEnv { #[must_use] pub fn info() -> String { - let version = env!("CARGO_PKG_VERSION"); + let version = VERSION; let codename = "celluloid"; format!("Hatsu v{version} \"{codename}\"") diff --git a/crates/utils/src/lib.rs b/crates/utils/src/lib.rs index 2eb3d1fa..0df752c7 100644 --- a/crates/utils/src/lib.rs +++ b/crates/utils/src/lib.rs @@ -3,6 +3,8 @@ pub mod date; mod error; pub mod markdown; pub mod url; +mod version; pub use data::{AppData, AppEnv}; pub use error::AppError; +pub use version::VERSION; diff --git a/crates/utils/src/version.rs b/crates/utils/src/version.rs new file mode 100644 index 00000000..9d8f5293 --- /dev/null +++ b/crates/utils/src/version.rs @@ -0,0 +1 @@ +pub const VERSION: &str = env!("CARGO_PKG_VERSION");