-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathpublish-symbol-service.ps1
62 lines (52 loc) · 1.87 KB
/
publish-symbol-service.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
Set-PSDebug -Strict
$ErrorActionPreference = 'Stop'
$VerbosePreference = 'Continue'
Set-Location $PSScriptRoot
function Get-OSRID() {
if ([environment]::Is64BitOperatingSystem -and [Runtime.InteropServices.RuntimeInformation]::IsOSPlatform([Runtime.InteropServices.OSPlatform]::Windows)) {
return 'win-x64'
}
if ([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform([Runtime.InteropServices.OSPlatform]::OSX)) {
return 'osx-x64'
}
if ([environment]::Is64BitOperatingSystem -and [Runtime.InteropServices.RuntimeInformation]::IsOSPlatform([Runtime.InteropServices.OSPlatform]::Linux)) {
return 'linux-x64'
}
}
function Get-SavedCommitHash() {
if (-not (test-path dotnet-symbol-service-last-commit -pathtype leaf)) {
return [string]::Empty
}
Get-Content -Path dotnet-symbol-service-last-commit | select-object -first 1
}
function Set-SavedCommitHash([string] $commitHash) {
Set-Content -Path dotnet-symbol-service-last-commit -Value $commitHash
}
function Get-LastCommit([string] $sinceCommitHash) {
if ($sinceCommitHash -eq [string]::Empty) {
$log = git log --oneline dotnet-symbol-service | select-object -first 1
} else {
$log = git log "$sinceCommitHash..HEAD" --oneline dotnet-symbol-service | select-object -first 1
}
if ($log -eq $null) {
return $null
}
$log.substring(0, $log.indexof(' '))
}
function Invoke-Publish() {
push-location 'dotnet-symbol-service'
dotnet publish -c Release -r (Get-OSRID) -o .\publish
if ($LASTEXITCODE -ne 0) {
write-error "Failed to publish with exit code $LASTEXITCODE"
exit $LASTEXITCODE
}
pop-location
}
$savedCommitHash = Get-SavedCommitHash
$lastCommitHash = Get-LastCommit $savedCommitHash
if ($lastCommitHash -eq $null) {
exit 0
}
Invoke-Publish
Set-SavedCommitHash $lastCommitHash
exit 0