-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathversion.ps1
More file actions
149 lines (125 loc) · 4.45 KB
/
version.ps1
File metadata and controls
149 lines (125 loc) · 4.45 KB
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
# KREA Version Manager
# PowerShell script for version management
param(
[Parameter(Mandatory=$false)]
[ValidateSet("patch", "minor", "major")]
[string]$Type = "patch",
[Parameter(Mandatory=$false)]
[string]$Message = "Version update",
[Parameter(Mandatory=$false)]
[switch]$Show,
[Parameter(Mandatory=$false)]
[switch]$Help
)
function Show-Help {
Write-Host "KREA Version Manager" -ForegroundColor Green
Write-Host "===================" -ForegroundColor Green
Write-Host ""
Write-Host "Kullanım:"
Write-Host " .\version.ps1 -Type [patch|minor|major] -Message 'Açıklama'"
Write-Host " .\version.ps1 -Show # Mevcut versiyon bilgisi"
Write-Host " .\version.ps1 -Help # Bu yardım"
Write-Host ""
Write-Host "Örnekler:"
Write-Host " .\version.ps1 -Type patch -Message 'Bug fix'"
Write-Host " .\version.ps1 -Type minor -Message 'New feature'"
Write-Host " .\version.ps1 -Type major -Message 'Breaking changes'"
Write-Host ""
Write-Host "Version Types:"
Write-Host " patch - 1.0.0 -> 1.0.1 (Bug fixes)"
Write-Host " minor - 1.0.0 -> 1.1.0 (New features)"
Write-Host " major - 1.0.0 -> 2.0.0 (Breaking changes)"
}
function Get-CurrentVersion {
if (Test-Path "version.json") {
$versionData = Get-Content "version.json" | ConvertFrom-Json
return $versionData
} else {
Write-Error "version.json dosyası bulunamadı!"
return $null
}
}
function Update-Version {
param($CurrentData, $VersionType, $UpdateMessage)
$version = $CurrentData.version
$parts = $version.Split('.')
$major = [int]$parts[0]
$minor = [int]$parts[1]
$patch = [int]$parts[2]
switch ($VersionType) {
"major" {
$major++
$minor = 0
$patch = 0
}
"minor" {
$minor++
$patch = 0
}
"patch" {
$patch++
}
}
$newVersion = "$major.$minor.$patch"
$currentDate = Get-Date -Format "yyyy-MM-dd"
# Version.json güncelle
$CurrentData.version = $newVersion
$CurrentData.releaseDate = $currentDate
$CurrentData.buildNumber = $CurrentData.buildNumber + 1
# Changelog'e yeni giriş ekle
$newEntry = @{
version = $newVersion
date = $currentDate
type = $VersionType
changes = @($UpdateMessage)
}
# Changelog array'in başına ekle
$CurrentData.changelog = @($newEntry) + $CurrentData.changelog
return $CurrentData
}
function Save-Version {
param($VersionData)
$json = $VersionData | ConvertTo-Json -Depth 10 -Compress:$false
$json | Set-Content "version.json" -Encoding UTF8
}
# Ana işlem
if ($Help) {
Show-Help
exit 0
}
$currentData = Get-CurrentVersion
if (-not $currentData) {
exit 1
}
if ($Show) {
Write-Host "KREA Version Info" -ForegroundColor Cyan
Write-Host "=================" -ForegroundColor Cyan
Write-Host "Current Version: $($currentData.version)" -ForegroundColor Green
Write-Host "Release Date: $($currentData.releaseDate)" -ForegroundColor Yellow
Write-Host "Build Number: $($currentData.buildNumber)" -ForegroundColor Blue
Write-Host ""
Write-Host "Recent Changes:" -ForegroundColor Magenta
$currentData.changelog | Select-Object -First 3 | ForEach-Object {
Write-Host " v$($_.version) ($($_.date)): $($_.changes -join ', ')" -ForegroundColor Gray
}
exit 0
}
# Version güncelle
Write-Host "Updating version ($Type): $Message" -ForegroundColor Yellow
$updatedData = Update-Version -CurrentData $currentData -VersionType $Type -UpdateMessage $Message
Save-Version -VersionData $updatedData
Write-Host "Version updated successfully!" -ForegroundColor Green
Write-Host "New version: $($updatedData.version)" -ForegroundColor Cyan
Write-Host "Build: $($updatedData.buildNumber)" -ForegroundColor Blue
# Git'e commit yap (opsiyonel)
$commitChoice = Read-Host "Git commit yapmak istiyor musunuz? (y/n)"
if ($commitChoice -eq "y" -or $commitChoice -eq "Y") {
git add .
git commit -m "Bump version to $($updatedData.version): $Message"
Write-Host "Git commit completed!" -ForegroundColor Green
$pushChoice = Read-Host "Git push yapmak istiyor musunuz? (y/n)"
if ($pushChoice -eq "y" -or $pushChoice -eq "Y") {
git push origin master
Write-Host "Git push completed!" -ForegroundColor Green
}
}