-
Notifications
You must be signed in to change notification settings - Fork 237
/
bump-version.nu
executable file
·63 lines (54 loc) · 2.35 KB
/
bump-version.nu
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/env nu
use std log
# bump the minor or patch version of the Nushell project
def main [
--patch # 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 $'version = "($version)"' $'version = "($new_version)"'
| save --force $file.name
}
"crates/nu-utils/src/default_files/doc_{config,env}.nu" | str expand | each {|file|
log debug $"bumping ($file) from ($version) to ($new_version)"
open --raw $file
| str replace --all $'version = "($version)"' $'version = "($new_version)"'
| save --force $file
}
"crates/nu-utils/src/default_files/default_{config,env}.nu" | str expand | each {|file|
log debug $"bumping ($file) from ($version) to ($new_version)"
open --raw $file
| str replace --all $'version = "($version)"' $'version = "($new_version)"'
| save --force $file
}
"crates/nu-utils/src/default_files/scaffold_{config,env}.nu" | str expand | each {|file|
log debug $"bumping ($file) from ($version) to ($new_version)"
open --raw $file
| str replace --all $'version = "($version)"' $'version = "($new_version)"'
| save --force $file
}
[
"crates/nu_plugin_python/nu_plugin_python_example.py"
"crates/nu_plugin_nu_example/nu_plugin_nu_example.nu"
] | each {|file|
log debug $"bumping ($file) from ($version) to ($new_version)"
open --raw $file
| str replace --all $'NUSHELL_VERSION = "($version)"' $'NUSHELL_VERSION = "($new_version)"'
| save --force $file
}
null
}