-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathPublish-LanguageServer.ps1
50 lines (37 loc) · 1.42 KB
/
Publish-LanguageServer.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
$dotnet = Get-Command 'dotnet'
$latestTag = git describe --tags --abbrev=0
if ($latestTag -notmatch '^(v)?\d+\.\d+\.\d+(-.*)?$') {
Write-Host "Latest tag doesn't follow semantic version format. The format is [v]major.minor.patch[-suffix]"
exit
}
if ($latestTag.StartsWith('v')) {
$latestTag = $latestTag.Substring(1)
}
$parts = $latestTag.Split('-')
$versionPrefix = $parts[0]
if ($parts.Count -gt 1) {
$versionSuffix = $parts[1]
}
if ($args -contains '--dev') {
$buildConfiguration = 'Debug'
if ($versionSuffix -eq '') {
$versionSuffix = "$versionSuffix-"
}
$versionSuffix = $versionSuffix + 'dev'
} else {
$buildConfiguration = 'Release'
}
$latestTagFull = git describe --tags
$latestTagShort = git describe --tags --abbrev=0
if ($latestTagFull -ceq $latestTagShort) {
$numberOfCommits = 0
} else {
$diff = $latestTagFull -replace $latestTagShort, ""
$numberOfCommits = $diff.Split('-')[1]
}
$fileVersion = "$versionPrefix.$numberOfCommits"
Write-Output "Chosen build configuration: $buildConfiguration"
$serverRoot = Join-Path $PSScriptRoot 'lib\server'
$publishRoot = Join-Path $PSScriptRoot ''
& $dotnet restore "$serverRoot\MSBuildProjectTools.sln"
& $dotnet publish "$serverRoot\src\LanguageServer\LanguageServer.csproj" -o "$publishRoot\language-server" /p:VersionPrefix="$versionPrefix" /p:VersionSuffix="$versionSuffix" /p:FileVersion="$fileVersion" -c $buildConfiguration