forked from jburzynski/TypeGen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
version-update.ps1
54 lines (42 loc) · 1.91 KB
/
version-update.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
if (-not ($args.length -eq 2)) {
Write-Host "Usage: ./version-update [old-version] [new-version]"
exit
}
$versionRegex = "\d+\.\d+\.\d+"
$oldVersion = $args[0]
$newVersion = $args[1]
if (-not ($oldVersion -match $versionRegex) -or -not ($newVersion -match $versionRegex)) {
Write-Host "Wrong version format. Should be: $($versionRegex)"
exit
}
# replace files' contents
$nuspecPath = "nuget\TypeGen.nuspec"
if (Test-Path $nuspecPath) {
(Get-Content $nuspecPath).Replace("<version>$($oldVersion)</version>", "<version>$($newVersion)</version>") | Set-Content $nuspecPath
}
$dotNetCliNuspecPath = "nuget-dotnetcli\TypeGen.DotNetCli.nuspec"
if (Test-Path $dotNetCliNuspecPath) {
(Get-Content $dotNetCliNuspecPath).Replace("<version>$($oldVersion)</version>", "<version>$($newVersion)</version>") | Set-Content $dotNetCliNuspecPath
#.Replace("id=""TypeGen"" version=""$($oldVersion)""", "id=""TypeGen"" version=""$($newVersion)""")
}
$docsConfPath = "..\TypeGenDocs\source\conf.py"
if (Test-Path $docsConfPath) {
(Get-Content $docsConfPath).Replace("version = u'$($oldVersion)'", "version = u'$($newVersion)'") | Set-Content $docsConfPath
}
$appConfigPath = "src\TypeGen\TypeGen.Cli\AppConfig.cs"
if (Test-Path $appConfigPath) {
(Get-Content $appConfigPath).Replace("Version => ""$($oldVersion)""", "Version => ""$($newVersion)""") | Set-Content $appConfigPath
}
$nugetUpdatePath = "nuget-update.ps1"
if (Test-Path $nugetUpdatePath) {
(Get-Content $nugetUpdatePath).Replace("TypeGen.$($oldVersion)", "TypeGen.$($newVersion)").Replace("TypeGen.DotNetCli.$($oldVersion)", "TypeGen.DotNetCli.$($newVersion)") | Set-Content $nugetUpdatePath
}
# remove old NuGet package
$oldNupkgPath = "nuget\TypeGen.$($oldVersion).nupkg"
if (Test-Path $oldNupkgPath) {
rm $oldNupkgPath
}
$oldDotNetCliNupkgPath = "nuget-dotnetcli\TypeGen.DotNetCli.$($oldVersion).nupkg"
if (Test-Path $oldDotNetCliNupkgPath) {
rm $oldDotNetCliNupkgPath
}