diff --git a/Cargo.lock b/Cargo.lock index 4a50f8a12..5e46fa1a0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -9216,6 +9216,16 @@ dependencies = [ "syn 2.0.67", ] +[[package]] +name = "subtensor-tools" +version = "0.1.0" +dependencies = [ + "anyhow", + "clap", + "semver 1.0.23", + "toml_edit 0.22.14", +] + [[package]] name = "subtle" version = "1.0.0" diff --git a/Cargo.toml b/Cargo.toml index 4a7565a01..e8d94e157 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,6 +4,7 @@ members = [ "pallets/commitments", "pallets/subtensor", "runtime", + "support/tools", "support/macros", ] resolver = "2" diff --git a/pallets/subtensor/rpc/Cargo.toml b/pallets/subtensor/rpc/Cargo.toml index db2f5f147..861c313d8 100644 --- a/pallets/subtensor/rpc/Cargo.toml +++ b/pallets/subtensor/rpc/Cargo.toml @@ -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"] diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml index 042d0337c..60c8fa22e 100644 --- a/runtime/Cargo.toml +++ b/runtime/Cargo.toml @@ -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 = [ diff --git a/scripts/publish.sh b/scripts/publish.sh new file mode 100644 index 000000000..3eb0fc6a5 --- /dev/null +++ b/scripts/publish.sh @@ -0,0 +1,28 @@ +#!/bin/bash +set -ex +cd support/macros +cargo publish +cd ../.. +cd pallets/commitments +cargo publish +cd .. +cd collective +cargo publish +cd .. +cd registry +cargo publish +cd .. +cd subtensor +cargo publish +cd runtime-api +cargo publish +cd ../.. +cd admin-utils +cargo publish +cd ../.. +cd runtime +cargo publish +cd .. +cd node +cargo publish +echo "published successfully." diff --git a/support/tools/Cargo.toml b/support/tools/Cargo.toml new file mode 100644 index 000000000..fa3e1fd50 --- /dev/null +++ b/support/tools/Cargo.toml @@ -0,0 +1,19 @@ +[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" +clap = { version = "4.5", features = ["derive"] } +semver = "1.0" +toml_edit = "0.22" diff --git a/support/tools/src/bump_version.rs b/support/tools/src/bump_version.rs new file mode 100644 index 000000000..a16293c30 --- /dev/null +++ b/support/tools/src/bump_version.rs @@ -0,0 +1,49 @@ +use clap::Parser; +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", +]; + +#[derive(Parser)] +struct CliArgs { + #[arg(required = true)] + version: Version, +} + +fn main() -> anyhow::Result<()> { + let args = CliArgs::parse(); + let version = args.version; + + 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())?; + } + + Ok(()) +}