forked from ravendb/ravendb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild_utils.ps1
94 lines (82 loc) · 2.24 KB
/
build_utils.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
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
Set-Variable CUSTOM_BUILD_NUMBER -option Constant -value "13"
function Get-File-Exists-On-Path
{
param(
[string]$file
)
$results = ($Env:Path).Split(";") | Get-ChildItem -filter $file -erroraction silentlycontinue
$found = ($results -ne $null)
return $found
}
function Get-Git-Commit
{
if ((Get-File-Exists-On-Path "git.exe")){
$gitLog = git log --oneline -1
return $gitLog.Split(' ')[0]
}
else {
return "0000000"
}
}
function Get-Git-Commit-Full
{
if ((Get-File-Exists-On-Path "git.exe")){
$gitLog = git log -1 --format="%H"
return $gitLog;
}
else {
return "0000000000000000000000000000000000000000"
}
}
function Get-DependencyPackageFiles
{
param([string]$packageName, [string]$frameworkVersion = "net45")
$fullPackageName = Get-ChildItem "$base_dir\packages\$packageName.*" |
Sort-Object Name -Descending |
Select-Object -First 1
Return "$fullPackageName\lib\$frameworkVersion\*"
}
Function Get-PackagePath {
Param([string]$packageName)
$packagePath = Get-ChildItem "$packages_dir\$packageName.*" |
Sort-Object Name -Descending |
Select-Object -First 1
Return "$packagePath"
}
function Get-InformationalVersion($version, $label, $category)
{
if (!$category) {
throw [System.ArgumentException] "Invalid build category $type"
}
if ($category.EndsWith("-Unstable") -or $category.EndsWith("-RC")) {
$result = "$version-rc-$label"
}
elseif ($category.EndsWith("-Hotfix")) {
$result = "$version-hotfix-$label"
}
elseif ($category.EndsWith("-Custom")) {
$result = "$version-custom-$label"
}
elseif ($category.EndsWith("-Patch")) {
$result = "$version-patch-$label"
}
elseif ($category -eq "RavenDB") {
$result = "$version"
}
else
{
throw [System.ArgumentException] "Invalid build category $type"
}
$result
}
function Get-BuildLabel
{
$result = ""
if($env:BUILD_NUMBER -ne $null) {
$result = $env:BUILD_NUMBER
}
else {
$result = $CUSTOM_BUILD_NUMBER
}
$result
}