-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbuild-docs.ps1
75 lines (60 loc) · 1.86 KB
/
build-docs.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
param (
[string]$Output = "./artifacts/gh-pages",
[string]$CurrentBranch = $Env:GITHUB_REF_NAME
)
# Utils
function EnsureLastExitCode($message){
if ($LASTEXITCODE -ne 0) {
throw $message
}
}
# Parameters
"----------------------------------------"
"Output: $Output"
$Location = Get-Location
"Location: $Location"
if ((Test-Path $output) -eq $True) {
"Clean: $Output"
Remove-Item -Recurse -Force $Output
}
# Git Information
"----------------------------------------"
if ($CurrentBranch -eq '') {
$CurrentBranch = git branch --show-current | Out-String
EnsureLastExitCode("git branch --show-current failed")
}
$CurrentBranch = $CurrentBranch.Trim()
"CurrentBranch: $CurrentBranch"
if ($CurrentBranch -eq '') {
Write-Error "Not branch or tag"
return
}
# Install tools
"----------------------------------------"
"Restoring dotnet tools"
dotnet tool restore
EnsureLastExitCode("Restore failed")
# Get GitVersion
"----------------------------------------"
"Getting GitVersion"
$Version = dotnet gitversion /output json /showvariable SemVer | Out-String -NoNewline
EnsureLastExitCode("Could not get SemVer from gitversion")
$Version = $Version.Trim()
"Git version: '$Version'"
"##vso[build.updatebuildnumber]$Version"
$PreReleaseTag = dotnet gitversion /output json /showvariable PreReleaseTag | Out-String -NoNewline
EnsureLastExitCode("Could not get PrReleaseTag from gitversion")
$PreReleaseTag = $PreReleaseTag.Trim()
$IsPreRelease = $PreReleaseTag -ne ''
"PreReleaseTag: $PreReleaseTag, IsPreRelease: $IsPreRelease"
"----------------------------------------"
"Docs"
$DocsOutput = $Output
$Basepath = "/tanka-graphql/"
"Output: $DocsOutput"
"BasePath: $Basepath"
dotnet tanka-docs build --output $DocsOutput --base $Basepath
EnsureLastExitCode("dotnet tanka-docs failed")
"----------------------------------------"
"DONE"
Set-Location $Location