-
Notifications
You must be signed in to change notification settings - Fork 168
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add bump-version binary to help with bumping all crate versions
- Loading branch information
1 parent
b43e889
commit 524a40e
Showing
7 changed files
with
81 additions
and
3 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
4.0.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(()) | ||
} |