Featurize self update
Some checks failed
Rust / check (push) Failing after 16s
Rust / build (push) Failing after 12s

This commit is contained in:
August 2025-08-27 21:20:13 -04:00
parent fb7ab4f6cc
commit ae10b786fe
Signed by: shibedrill
GPG Key ID: 5FE0CB25945EFAA2
5 changed files with 21 additions and 22 deletions

2
Cargo.lock generated
View File

@ -2378,7 +2378,7 @@ dependencies = [
[[package]]
name = "shibe-bot"
version = "1.0.2"
version = "1.1.0"
dependencies = [
"anyhow",
"dotenvy",

View File

@ -3,7 +3,7 @@ name = "shibe-bot"
description = "A Discord bot written in Rust, using Poise."
license = "MIT"
readme = "README.md"
version = "1.0.2"
version = "1.1.0"
edition = "2021"
build = "build.rs"
@ -24,9 +24,13 @@ serde_json = "1.0.140"
roux = "2.2.13"
structstruck = "0.5.0"
reqwest = { version = "0.12.15", features = ["json"] }
octocrab = "0.44.1"
tempfile = "3.20.0"
self-replace = "1.5.0"
zip = "4.2.0"
nix = { version = "0.30.1", features = ["process"] }
minreq = { version = "2.14.0", features = ["https"] }
octocrab = { version = "0.44.1", optional = true }
tempfile = { version = "3.20.0", optional = true }
self-replace = { version = "1.5.0", optional = true }
zip = { version = "4.2.0", optional = true }
nix = { version = "0.30.1", features = ["process"], optional = true }
minreq = { version = "2.14.0", features = ["https"], optional = true }
[features]
self-update=["octocrab", "tempfile", "self-replace", "zip", "nix", "minreq"]

View File

@ -1,4 +1,4 @@
# Shibe Bot 1.0.2
# Shibe Bot 1.1.0
[![Rust](https://github.com/shibedrill/shibe-bot/actions/workflows/rust.yml/badge.svg)](https://github.com/shibedrill/shibe-bot/actions/workflows/rust.yml)
[![GitHub License](https://img.shields.io/github/license/shibedrill/shibe-bot)](LICENSE.txt)

View File

@ -1,17 +1,9 @@
use std::convert::Infallible;
use std::os::unix::process::CommandExt;
#[cfg(feature="self-update")]
use {std::convert::Infallible, std::os::unix::process::CommandExt, octocrab, std::io::Write, self_replace, zip, minreq};
use crate::Context;
use crate::Error;
use octocrab;
use std::io::Write;
use self_replace;
use zip;
use minreq;
/// Print version and build information
#[poise::command(slash_command)]
pub async fn version(ctx: Context<'_>) -> Result<(), Error> {
@ -42,6 +34,7 @@ pub async fn version(ctx: Context<'_>) -> Result<(), Error> {
Ok(())
}
#[cfg(feature="self-update")]
/// Update the bot remotely (requires Github CI)
#[poise::command(slash_command, owners_only, hide_in_help)]
pub async fn update(
@ -121,6 +114,7 @@ pub async fn say(
Ok(())
}
#[cfg(feature="self-update")]
fn self_update() -> Result<Infallible, Error> {
let artifact_url = "https://nightly.link/shibedrill/shibe-bot/workflows/rust/main/artifact.zip";
let tempdir = tempfile::Builder::new().prefix("shibe-bot").tempdir()?;
@ -173,11 +167,11 @@ fn self_update() -> Result<Infallible, Error> {
mod test {
#[cfg(test)]
use crate::Error;
#[cfg(test)]
use std::convert::Infallible;
#[cfg(feature="self-update")]
use {crate::Error, std::convert::Infallible};
#[test]
#[cfg(feature="self-update")]
fn test_self_update() -> Result<Infallible, Error> {
use crate::command::devel::self_update;
use pretty_env_logger;

View File

@ -85,6 +85,7 @@ async fn main() {
shutdown(),
restart(),
say(),
#[cfg(feature="self-update")]
update(),
version(),
// Fun