-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathCreateRelease.ps1
55 lines (49 loc) · 1.67 KB
/
CreateRelease.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
param(
[Parameter()][AllowNull()]
[string]$Major,
[Parameter()][AllowNull()]
[string]$Minor,
[Parameter()][AllowNull()]
[string]$Patch
)
$appVersion = (git describe --match "*" main).replace("v", "").split(".")
$majorDefault = $appVersion[0]
$minorDefault = $appVersion[1]
$patchDefault = $appVersion[2]
if($patchDefault.Contains("-")){
$patchDefault = $appVersion[2].substring(0, $appVersion[2].Indexof("-"));
}
Function Version{
param(
[Parameter(Mandatory=$true)] [ValidateRange(0,9)] [Int]$Major,
[Parameter(Mandatory=$true)] [ValidateRange(0,9)] [Int]$Minor,
[Parameter(Mandatory=$true)] [ValidateRange(0,20)] [Int]$Patch
)
[int]$PatchInc = ($Patch + 3) -as [int];
if($PatchInc -gt 20){
$PatchInc = 0;
$Minor = $Minor + 1;
}
$Version = "$Major.$Minor.$PatchInc"
Write-Output "$Version"
$yesNo = Read-Host -prompt "Are you sure to release YouTuber ${Version}? [Y/N]"
if ($yesNo -eq 'y')
{
do
{
Write-output "Cleaning unused tags"
git fetch -p -P origin
Write-Output ${Version}
Write-output "Create tag Release"
git tag ${Version} -a -m "Release ${Version}"
Write-output "Push Release"
git push --tags
Write-output "$value"
}
while($strQuit -eq 'y')
}
}
$majorVal = If([string]::IsNullOrEmpty($Major)) {$majorDefault} else {$Major}
$minorVal = If([string]::IsNullOrEmpty($Minor)) {$minorDefault} else {$Minor}
$patchVal = If([string]::IsNullOrEmpty($Patch)) {$patchDefault} else {$Patch}
Version -Major $majorVal -Minor $minorVal -Patch $patchVal