diff --git a/make_release/Readme.md b/make_release/Readme.md index 39e7dcc..7be7412 100644 --- a/make_release/Readme.md +++ b/make_release/Readme.md @@ -24,9 +24,8 @@ - [ ] bump the version on the Nushell side ([example with `reedline`][reedline pin example]) (reference the release notes for courtesy) ## 1. Minor bump of the version ([example][nushell bump example]) -- [ ] bump the version with `sd 'version = "0.xx.1"' 'version = "0.xx+1.0"' **/Cargo.toml` -- [ ] bump the version info in the default configs with `sd 'version = 0.xx.1' 'version = 0.xx+1.0' **/*.nu` -- [ ] Also commit `Cargo.lock` AFTER running a cargo command (or update via `sd 'version = "0.xx.1"' 'version = "0.xx+1.0"' **/Cargo.lock` assuming no other package carries that version specifier) +- [ ] in the repo of Nushell, run `/path/to/nu_scripts/make_release/bump-version.nu` +- [ ] Also commit `Cargo.lock` AFTER running a Cargo command like `cargo check --workspace` ## 2. Tag the [`nushell`] repo > **Warning** @@ -86,7 +85,10 @@ - [ ] run `./make_release/release-note/create-pr 0.xx.0 ((date now) + 4wk | date format "%Y-%m-%d" | into datetime)` ## 8. Bump the version as development -- [ ] bump the patch version on [`nushell`] ([example][nushell dev example]) +- [ ] bump the patch version on [`nushell`] ([example][nushell dev example]) by running +```nushell +/path/to/nu_scripts/make_release/bump-version.nu --patch +``` [reedline bump example]: https://github.com/nushell/reedline/pull/596/files diff --git a/make_release/bump-version.nu b/make_release/bump-version.nu new file mode 100755 index 0000000..1d6a0a2 --- /dev/null +++ b/make_release/bump-version.nu @@ -0,0 +1,40 @@ +#!/usr/bin/env nu +use std log + +# bump the minor or patch version of the Nushell project +def main [ + --patch: bool # update the minor version instead of the minor +]: nothing -> nothing { + let version = open Cargo.toml + | get package.version + | parse "{major}.{minor}.{patch}" + | into int major minor patch + | into record + + let new_version = if $patch { + $version | update patch { $in + 1 } + } else { + $version | update minor { $in + 1 } | update patch { 0 } + } + + let version = $version | transpose | get column1 | str join "." + let new_version = $new_version | transpose | get column1 | str join "." + + log info $"bumping all packages and Nushell files in (open Cargo.toml | get package.name) from ($version) to ($new_version)" + + ls **/Cargo.toml | each {|file| + log debug $"bumping ($file.name) from ($version) to ($new_version)" + open --raw $file.name + | str replace --all --string $'version = "($version)"' $'version = "($new_version)"' + | save --force $file.name + } + + "crates/nu-utils/src/sample_config/default_{config,env}.nu" | str expand | each {|file| + log debug $"bumping ($file) from ($version) to ($new_version)" + open --raw $file + | str replace --all --string $'version = ($version)' $'version = ($new_version)' + | save --force $file + } + + null +}