Skip to content

Commit

Permalink
Add bump-version binary to help with bumping all crate versions
Browse files Browse the repository at this point in the history
  • Loading branch information
keithtensor committed Aug 8, 2024
1 parent b43e889 commit 524a40e
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 3 deletions.
9 changes: 9 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ members = [
"pallets/commitments",
"pallets/subtensor",
"runtime",
"support/tools",
"support/macros",
]
resolver = "2"
Expand Down
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
4.0.0
4 changes: 2 additions & 2 deletions pallets/subtensor/rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ sp-runtime = { workspace = true }

# local packages

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

[features]
default = ["std"]
Expand Down
2 changes: 1 addition & 1 deletion runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ path = "src/spec_version.rs"

[dependencies]
subtensor-macros.workspace = true
subtensor-custom-rpc-runtime-api = { version = "0.0.2", path = "../pallets/subtensor/runtime-api", default-features = false }
subtensor-custom-rpc-runtime-api = { path = "../pallets/subtensor/runtime-api", default-features = false }
smallvec = { workspace = true }
log = { workspace = true }
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = [
Expand Down
18 changes: 18 additions & 0 deletions support/tools/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[package]
name = "subtensor-tools"
version = "0.1.0"
edition = "2021"
license = "MIT"

description = "support tools for Subtensor"
repository = "https://github.com/opentensor/subtensor"
homepage = "https://bittensor.com"

[[bin]]
name = "bump-version"
path = "src/bump_version.rs"

[dependencies]
anyhow = "1.0"
semver = "1.0"
toml_edit = "0.22"
49 changes: 49 additions & 0 deletions support/tools/src/bump_version.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
use semver::Version;
use std::{
fs,
io::{Read, Seek, Write},
str::FromStr,
};
use toml_edit::{DocumentMut, Item, Value};

const TOML_PATHS: [&str; 9] = [
"support/macros",
"pallets/commitments",
"pallets/collective",
"pallets/registry",
"pallets/subtensor",
"pallets/subtensor/runtime-api",
"pallets/admin-utils",
"runtime",
"node",
];

fn main() -> anyhow::Result<()> {
let mut version_file = fs::File::options().read(true).write(true).open("VERSION")?;
let mut version_str = String::new();
version_file.read_to_string(&mut version_str)?;
let mut version = Version::parse(&version_str)?;
version.minor = version.minor.saturating_add(1);

for path in TOML_PATHS {
let cargo_toml_path = format!("{path}/Cargo.toml");
let mut toml_file = fs::File::options()
.read(true)
.write(true)
.open(&cargo_toml_path)?;
let mut toml_str = String::new();
toml_file.read_to_string(&mut toml_str)?;
let mut modified_toml_doc = DocumentMut::from_str(&toml_str)?;

modified_toml_doc["package"]["version"] = Item::Value(Value::from(version.to_string()));
toml_file.set_len(0)?;
toml_file.rewind()?;
toml_file.write_all(modified_toml_doc.to_string().as_bytes())?;
}

version_file.set_len(0)?;
version_file.rewind()?;
version_file.write_all(version.to_string().as_bytes())?;

Ok(())
}

0 comments on commit 524a40e

Please sign in to comment.