-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathversion.ps1
40 lines (36 loc) · 1.01 KB
/
version.ps1
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
if((git tag | measure).Count -eq 0) {
write-host "there are no tags!" -f red
exit 1
}
$parts = "$(git describe --abbrev=0 --tags)".Split('.')
$major = [int] ($parts[0])
$minor = [int] ($parts[1])
$patch = [int] ($parts[2])
write-host "current version: " -n; write-host "$major.$minor.$patch" -f yellow
switch ($args[0]) {
"" {
exit 0
}
"patch" {
$patch++
}
"minor" {
$patch = 0
$minor++
}
"major" {
$patch = 0
$minor = 0
$major++
}
Default {
write-host "Wrong command!" -f red
write-host "Type:"
write-host " ./version.ps1 patch " -f yellow -n; write-host "to bump patch version"
write-host " ./version.ps1 minor " -f yellow -n; write-host "to bump minor version"
write-host " ./version.ps1 major " -f yellow -n; write-host "to bump major version"
exit 1
}
}
# git tag "$major.$minor.$patch"
write-host "version changed to " -n; write-host "$major.$minor.$patch" -f yellow