-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathPatchVersion.ps1
More file actions
30 lines (24 loc) · 809 Bytes
/
PatchVersion.ps1
File metadata and controls
30 lines (24 loc) · 809 Bytes
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
# check whether build on tag
$version = "DEVEL"
Write-Host ref = $env:GITHUB_REF
if ($env:GITHUB_REF -match "/tags/") {
# use tag as version name
Write-Host building tag...
$version = $env:GITHUB_REF -replace "(\w+/)*",""
} else {
if ($env:GITHUB_REF -match "/pull/") {
# use branch as version name base
Write-Host building PR...
$version = $env:GITHUB_PR_REF
}
# use git sha as version name
$version = $version + "-" + ($env:GITHUB_SHA).Substring(0, 8)
}
Write-Host version = $version
$file = gi .\src\SimpleAccounting\SimpleAccounting.csproj
$xml = [xml](gc $file)
$xml.Project.PropertyGroup.InformationalVersion = $version
$utf8 = New-Object System.Text.UTF8Encoding($true)
$sw = New-Object System.IO.StreamWriter($file.Fullname, $false, $utf8)
$xml.Save( $sw )
$sw.Close()