-
Notifications
You must be signed in to change notification settings - Fork 8
/
Update-AppVersion.ps1
36 lines (27 loc) · 1002 Bytes
/
Update-AppVersion.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
function Update-AppVersion
{
$configFile = "config.xml"
$buildNumber = $env:BUILD_BUILDNUMBER
if($buildNumber -eq $null){
$buildNumber = 0
}
$version = "0.0.0";
$versionCode = (Get-Date).ToString("yyyyMM") + $buildNumber
$matches = (Get-Content $configFile) | Select-String 'version="(\d+(\.\d+){1,3})"'
if($matches){
$version = $matches[0].Matches.Groups[1].Value
}
$versionPoints = $version.Split('.')
$major = $versionPoints[0]
$minor = $versionPoints[1]
$patch = $versionPoints[2]
$version = "$major.$minor.$patch.$buildNumber"
Write-Verbose "Version $version" -Verbose
Write-Verbose "VersionCode $versionCode" -Verbose
(Get-Content $configFile) |
%{$_ -replace 'android-versionCode="\d+"', "android-versionCode=""$versionCode""" } |
%{$_ -replace 'version="\d+(\.\d+){1,3}"', "version=""$version""" } |
Set-Content $configFile -Force
return $version
}
Update-AppVersion