Skip to content

Commit 524a40e

Browse files
committed
Add bump-version binary to help with bumping all crate versions
1 parent b43e889 commit 524a40e

File tree

7 files changed

+81
-3
lines changed

7 files changed

+81
-3
lines changed

Diff for: Cargo.lock

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

Diff for: Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ members = [
44
"pallets/commitments",
55
"pallets/subtensor",
66
"runtime",
7+
"support/tools",
78
"support/macros",
89
]
910
resolver = "2"

Diff for: VERSION

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
4.0.0

Diff for: pallets/subtensor/rpc/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ sp-runtime = { workspace = true }
2626

2727
# local packages
2828

29-
subtensor-custom-rpc-runtime-api = { version = "0.0.2", path = "../runtime-api", default-features = false }
30-
pallet-subtensor = { version = "4.0.0-dev", path = "../../subtensor", default-features = false }
29+
subtensor-custom-rpc-runtime-api = { path = "../runtime-api", default-features = false }
30+
pallet-subtensor = { path = "../../subtensor", default-features = false }
3131

3232
[features]
3333
default = ["std"]

Diff for: runtime/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ path = "src/spec_version.rs"
2121

2222
[dependencies]
2323
subtensor-macros.workspace = true
24-
subtensor-custom-rpc-runtime-api = { version = "0.0.2", path = "../pallets/subtensor/runtime-api", default-features = false }
24+
subtensor-custom-rpc-runtime-api = { path = "../pallets/subtensor/runtime-api", default-features = false }
2525
smallvec = { workspace = true }
2626
log = { workspace = true }
2727
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = [

Diff for: support/tools/Cargo.toml

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
[package]
2+
name = "subtensor-tools"
3+
version = "0.1.0"
4+
edition = "2021"
5+
license = "MIT"
6+
7+
description = "support tools for Subtensor"
8+
repository = "https://github.com/opentensor/subtensor"
9+
homepage = "https://bittensor.com"
10+
11+
[[bin]]
12+
name = "bump-version"
13+
path = "src/bump_version.rs"
14+
15+
[dependencies]
16+
anyhow = "1.0"
17+
semver = "1.0"
18+
toml_edit = "0.22"

Diff for: support/tools/src/bump_version.rs

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
use semver::Version;
2+
use std::{
3+
fs,
4+
io::{Read, Seek, Write},
5+
str::FromStr,
6+
};
7+
use toml_edit::{DocumentMut, Item, Value};
8+
9+
const TOML_PATHS: [&str; 9] = [
10+
"support/macros",
11+
"pallets/commitments",
12+
"pallets/collective",
13+
"pallets/registry",
14+
"pallets/subtensor",
15+
"pallets/subtensor/runtime-api",
16+
"pallets/admin-utils",
17+
"runtime",
18+
"node",
19+
];
20+
21+
fn main() -> anyhow::Result<()> {
22+
let mut version_file = fs::File::options().read(true).write(true).open("VERSION")?;
23+
let mut version_str = String::new();
24+
version_file.read_to_string(&mut version_str)?;
25+
let mut version = Version::parse(&version_str)?;
26+
version.minor = version.minor.saturating_add(1);
27+
28+
for path in TOML_PATHS {
29+
let cargo_toml_path = format!("{path}/Cargo.toml");
30+
let mut toml_file = fs::File::options()
31+
.read(true)
32+
.write(true)
33+
.open(&cargo_toml_path)?;
34+
let mut toml_str = String::new();
35+
toml_file.read_to_string(&mut toml_str)?;
36+
let mut modified_toml_doc = DocumentMut::from_str(&toml_str)?;
37+
38+
modified_toml_doc["package"]["version"] = Item::Value(Value::from(version.to_string()));
39+
toml_file.set_len(0)?;
40+
toml_file.rewind()?;
41+
toml_file.write_all(modified_toml_doc.to_string().as_bytes())?;
42+
}
43+
44+
version_file.set_len(0)?;
45+
version_file.rewind()?;
46+
version_file.write_all(version.to_string().as_bytes())?;
47+
48+
Ok(())
49+
}

0 commit comments

Comments
 (0)