-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrelease.nu
executable file
·34 lines (23 loc) · 1.1 KB
/
release.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
#!/usr/bin/env nu
# Make sure we've committed all our changes.
let GIT_STATUS = (git status --porcelain | lines)
if (($GIT_STATUS | length) != 0) {
print $"(ansi red_bold) [Error](ansi reset): Working directory must be clean"
print $"(ansi blue_bold)~~~ Git Status ~~~.(ansi reset)"
print $GIT_STATUS
print $"(ansi red_bold)Release Aborted.(ansi reset)"
exit 1;
}
let CARGO_TOML_VERSION = (open Cargo.toml | get "package" | get "version")
print $"(ansi blue_bold) [INFO]:(ansi reset) Cargo.toml Release Version is: (ansi green_bold)($CARGO_TOML_VERSION)(ansi reset)"
let EXISTING_VERSION_CONFLICT = (git tag | lines | str substring 1.. | any {|line| $line == $CARGO_TOML_VERSION})
if $EXISTING_VERSION_CONFLICT {
print $"(ansi red_bold) [ERROR](ansi reset): Version ($CARGO_TOML_VERSION) is already an existing git tag. Consider updating Cargo.toml. (ansi red_bold) Aborting(ansi reset)."
exit 1;
}
## so if we're up to date locally, and we don't have a tag conflict
## we can
## 1. Create a tag
git tag $"v($CARGO_TOML_VERSION)"
## 2. Push that tag to github to start ci
git push --tags