Skip to content

Commit 188a8d8

Browse files
authored
Merge pull request #720 from opentensor/crates-io-publish-script
Create publish script to publish crates in the correct order
2 parents 6ff7b3f + 9e98762 commit 188a8d8

File tree

7 files changed

+110
-3
lines changed

7 files changed

+110
-3
lines changed

Diff for: Cargo.lock

+10
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: 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: scripts/publish.sh

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/bash
2+
set -ex
3+
cd support/macros
4+
cargo publish
5+
cd ../..
6+
cd pallets/commitments
7+
cargo publish
8+
cd ..
9+
cd collective
10+
cargo publish
11+
cd ..
12+
cd registry
13+
cargo publish
14+
cd ..
15+
cd subtensor
16+
cargo publish
17+
cd runtime-api
18+
cargo publish
19+
cd ../..
20+
cd admin-utils
21+
cargo publish
22+
cd ../..
23+
cd runtime
24+
cargo publish
25+
cd ..
26+
cd node
27+
cargo publish
28+
echo "published successfully."

Diff for: support/tools/Cargo.toml

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

0 commit comments

Comments
 (0)