Skip to content

Commit

Permalink
Version 1.30.0 (#594)
Browse files Browse the repository at this point in the history
* Changelog updates
* Version bump with utilities
  • Loading branch information
paupino authored Jun 15, 2023
1 parent 714db9c commit 9787b1d
Show file tree
Hide file tree
Showing 8 changed files with 118 additions and 7 deletions.
3 changes: 3 additions & 0 deletions .buildnumber
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
1
30
0
23 changes: 21 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
# Version History

## 1.30.0

As the minor releases for Rust Decimal are getting smaller, I'll be looking at formally starting version 2 of the
Decimal library. This will be unstable as we find experiment with a new API and address some of the constraints the current
implementation of the library has (e.g. revised error types for better const support).

### Added

* Add `proptest` feature support for `Decimal` ([#582](https://github.com/paupino/rust-decimal/pull/582)).
* Implement an `is_integer` function for an efficient means to check whether a `Decimal` is an integer with no fractional portion. ([#591](https://github.com/paupino/rust-decimal/pull/591)).

### Changed

* Improved GitHub Actions Workflow ([#592](https://github.com/paupino/rust-decimal/pull/592)).

### Credit

Thank you to [@cardoe](https://github.com/cardoe/) for your contribution!

## 1.29.1

### Fixed
Expand All @@ -14,14 +33,14 @@

### Fixed

* Fix issue when rouding using a high precision decimal place on zero values. This would previously allow the `Decimal` number to enter into an invalid state. ([#575](https://github.com/paupino/rust-decimal/pull/575))
* Fix issue when rounding using a high precision decimal place on zero values. This would previously allow the `Decimal` number to enter into an invalid state. ([#575](https://github.com/paupino/rust-decimal/pull/575))

### Changed

There were also a couple of housekeeping tasks, to help pave the way for v2 of Rust Decimal.

* Clean up features so that they are explicit in the `cargo.toml` and leverage the new `dep:` syntax where required. ([#579](https://github.com/paupino/rust-decimal/pull/579))
* Restructure and compartamentalize Makefile. ([#580](https://github.com/paupino/rust-decimal/pull/580))
* Restructure and compartmentalize Makefile. ([#580](https://github.com/paupino/rust-decimal/pull/580))

### Credit

Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ name = "rust_decimal"
readme = "./README.md"
repository = "https://github.com/paupino/rust-decimal"
rust-version = "1.60"
version = "1.29.1"
version = "1.30.0"

[package.metadata.docs.rs]
all-features = true
Expand Down
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ Alternatively, you can edit your `Cargo.toml` directly and run `cargo update`:

```toml
[dependencies]
rust_decimal = "1.29"
rust_decimal_macros = "1.29"
rust_decimal = "1.30"
rust_decimal_macros = "1.30"
```

## Usage
Expand Down Expand Up @@ -173,6 +173,10 @@ non-panicking behavior, please use the feature: `maths-nopanic`.

Enables arithmetic operations using [`ndarray`](https://github.com/rust-ndarray/ndarray) on arrays of `Decimal`.

### `proptest`

Enables a [`proptest`](https://github.com/proptest-rs/proptest) strategy to generate values for Rust Decimal.

### `rand`

Implements `rand::distributions::Distribution<Decimal>` to allow the creation of random instances.
Expand Down
2 changes: 1 addition & 1 deletion fuzz/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ authors = ["Automatically generated"]
edition = "2021"
name = "rust-decimal-fuzz"
publish = false
version = "0.0.0"
version = "1.30.0"

[package.metadata]
cargo-fuzz = true
Expand Down
2 changes: 1 addition & 1 deletion macros/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "rust_decimal_macros"
version = "1.29.1"
version = "1.30.0"
authors = ["Paul Mason <paul@form1.co.nz>"]
edition = "2021"
description = "Shorthand macros to assist creating Decimal types."
Expand Down
72 changes: 72 additions & 0 deletions make/scripts/version.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
//! ```cargo
//! [dependencies]
//! glob = "*"
//! ```
use glob::glob;
use std::env;
use std::error::Error;
use std::fs;
use std::io::{self, BufRead};

fn main() -> Result<(), Box<dyn Error>> {
let parent_dir = env::var("CARGO_MAKE_WORKING_DIRECTORY").expect("CARGO_MAKE_WORKING_DIRECTORY not specified");
let version_type = env::var("RUST_DECIMAL_BUILD_VERSION").expect("RUST_DECIMAL_BUILD_VERSION not specified");

// Load in the build number
let build_number = format!("{parent_dir}/.buildnumber");
let (major, minor, revision) = parse_build_number(&build_number, &version_type)?;
println!("{major}.{minor}.{revision}");

// Process all cargo files
for entry in glob("./**/Cargo.toml").expect("Failed to read glob pattern") {
let path = entry?;
let toml = fs::read_to_string(&path)?;
let mut updated_toml = String::new();
let mut added = false;
for line in toml.lines() {
if !added && line.starts_with("version =") {
added = true;
updated_toml.push_str(&format!("version = \"{major}.{minor}.{revision}\"\n"));
} else {
updated_toml.push_str(line);
updated_toml.push('\n');
}
}
fs::write(&path, updated_toml)?;
}

// Also, update the readme with the build number
let readme_path = format!("{parent_dir}/README.md");
let readme = fs::read_to_string(&readme_path)?;
let mut updated_readme = String::new();
for line in readme.lines() {
if line.starts_with("rust_decimal = \"") {
updated_readme.push_str(&format!("rust_decimal = \"{major}.{minor}\"\n"));
} else if line.starts_with("rust_decimal_macros = \"") {
updated_readme.push_str(&format!("rust_decimal_macros = \"{major}.{minor}\"\n"));
} else {
updated_readme.push_str(line);
updated_readme.push('\n');
}
}
fs::write(&readme_path, updated_readme)?;

// Finally, write the build number back
fs::write(build_number, format!("{major}\n{minor}\n{revision}\n",))?;
Ok(())
}

fn parse_build_number(path: &String, version_type: &String) -> Result<(u32, u32, u32), Box<dyn Error>> {
let file = fs::File::open(path)?;
let mut lines = io::BufReader::new(file).lines();
let major: u32 = lines.next().expect("missing major version")?.parse()?;
let minor: u32 = lines.next().expect("missing minor version")?.parse()?;
let revision: u32 = lines.next().expect("missing revision version")?.parse()?;
Ok(match &version_type[..] {
"major" => (major + 1, 0, 0),
"minor" => (major, minor + 1, 0),
"revision" => (major, minor, revision + 1),
_ => (major, minor, revision),
})
}
13 changes: 13 additions & 0 deletions make/utils.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,16 @@ args = ["clippy"]
install_crate = "cargo-outdated"
command = "cargo"
args = ["outdated", "-R"]

[tasks.version-minor]
env = { "RUST_DECIMAL_BUILD_VERSION" = "minor" }
run_task = "propagate-version"

[tasks.version-revision]
env = { "RUST_DECIMAL_BUILD_VERSION" = "revision" }
run_task = "propagate-version"

[tasks.propagate-version]
private = true
script_runner = "@rust"
script = { file = "${CARGO_MAKE_WORKING_DIRECTORY}/make/scripts/version.rs", absolute_path = true }

0 comments on commit 9787b1d

Please sign in to comment.