Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create publish script to publish crates in the correct order #720

Merged
merged 4 commits into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
28 changes: 28 additions & 0 deletions scripts/publish.sh
Original file line number Diff line number Diff line change
@@ -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."
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")?;
keithtensor marked this conversation as resolved.
Show resolved Hide resolved
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(())
}