Skip to content

Commit ddc2bb2

Browse files
committed
Added versioning
1 parent 1cdff47 commit ddc2bb2

File tree

5 files changed

+229
-7
lines changed

5 files changed

+229
-7
lines changed

Cargo.lock

+152-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
[package]
22
name = "mimicri"
3-
version = "0.1.0"
3+
version = "0.1.1"
44
edition = "2021"
5+
build = "build.rs"
56

67
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
78

@@ -30,3 +31,7 @@ features = ["full"]
3031

3132
[dependencies.dotenv]
3233
version = "0.15.0"
34+
35+
[build-dependencies]
36+
anyhow = "1.0.65"
37+
vergen = "7.4.2"

build.rs

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
use anyhow::Result;
2+
use vergen::{vergen, Config};
3+
4+
fn main() -> Result<()> {
5+
vergen(Config::default())
6+
}

publish.sh

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#! /bin/bash
2+
3+
# Possible arguments:
4+
# - patch (default)
5+
# - minor
6+
# - major
7+
8+
set -e
9+
10+
if [ "$1" == "" ] || [ "$1" == "patch" ]; then
11+
bump_type="patch"
12+
elif [ "$1" == "minor" ] || [ "$1" == "major" ]; then
13+
bump_type="$1"
14+
else
15+
echo "Invalid bump type. Possible arguments: 'patch' (default), 'minor', or 'major'."
16+
fi
17+
18+
# Check if dependencies install
19+
jq --version &> /dev/null
20+
if [ $? != 0 ]; then
21+
echo "Error: jq could not be found."
22+
exit
23+
fi
24+
25+
cargo bump --version &> /dev/null
26+
if [ $? != 0 ]; then
27+
echo "Error: cargo bump could not be found. Run 'cargo install cargo-bump'."
28+
exit
29+
fi
30+
31+
32+
previous_version=v$(cargo metadata --no-deps --format-version=1 | jq -r .packages[0].version)
33+
34+
cargo bump $bump_type
35+
cargo check
36+
37+
version=v$(cargo metadata --no-deps --format-version=1 | jq -r .packages[0].version)
38+
39+
echo "Bumped version from $previous_version to $version"
40+
41+
git add .
42+
git commit -m "Published $version" --allow-empty
43+
44+
git tag $version
45+
git push --tags

src/main.rs

+20-5
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,18 @@ impl EventHandler for Handler {
4545

4646
#[group]
4747
#[commands(
48-
deafen,
49-
join,
50-
leave,
51-
mute,
48+
version,
5249
play,
5350
ping,
5451
skip,
5552
queue,
5653
undeafen,
5754
unmute,
58-
now_playing
55+
now_playing,
56+
deafen,
57+
join,
58+
leave,
59+
mute
5960
)]
6061
struct General;
6162

@@ -107,6 +108,20 @@ async fn main() {
107108
println!("Received Ctrl-C, shutting down.");
108109
}
109110

111+
#[command]
112+
async fn version(ctx: &Context, msg: &Message, _args: Args) -> CommandResult {
113+
let message_ctx = MessageContext {
114+
channel: msg.channel_id,
115+
http: ctx.http.clone(),
116+
};
117+
118+
message_ctx
119+
.send_info(format!("Version: {}", env!("VERGEN_GIT_SEMVER")))
120+
.await;
121+
122+
Ok(())
123+
}
124+
110125
#[command]
111126
#[only_in(guilds)]
112127
async fn play(ctx: &Context, msg: &Message, args: Args) -> CommandResult {

0 commit comments

Comments
 (0)