-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.build.ps1
65 lines (51 loc) · 1.81 KB
/
main.build.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
<#
.Synopsis
Build script invoked by Invoke-Build.
.Description
#>
param(
[Parameter(Mandatory = $false)]
[string]$Version
)
task Publish Pack, {
Import-Module -Name Microsoft.PowerShell.SecretManagement
$apiKey = Get-Secret -Name 'TIKSN-ROFSDB-NuGet-ApiKey' -AsPlainText
$nupkg = Join-Path -Path $script:trashFolder -ChildPath "ROFSDB.$script:NextVersion.nupkg"
$nupkg = Resolve-Path -Path $nupkg
$nupkg = $nupkg.Path
Exec { nuget push $nupkg -ApiKey $apiKey -Source https://api.nuget.org/v3/index.json }
}
task Pack Test, EstimateVersions, {
$project = './src/ROFSDB/ROFSDB.csproj'
$project = Resolve-Path $project
$project = $project.Path
Exec { dotnet pack --configuration Release --output $script:trashFolder -p:version=$script:NextVersion $project }
}
task EstimateVersions {
$Version = [Version]$Version
Assert ($Version.Revision -eq -1) 'Version should be formatted as Major.Minor.Patch like 1.2.3'
Assert ($Version.Build -ne -1) 'Version should be formatted as Major.Minor.Patch like 1.2.3'
$Version = $Version.ToString()
$script:NextVersion = $Version
}
task Test Build, {
$project = Resolve-Path './src/ROFSDB.Tests/ROFSDB.Tests.csproj'
$project = $project.Path
Exec { dotnet test $project }
}
task Build Clean, {
$solution = Resolve-Path './src/ROFSDB.sln'
$solution = $solution.Path
Exec { dotnet restore $solution }
Exec { dotnet build $solution }
}
task Clean Init, {
}
task Init {
$date = Get-Date
$ticks = $date.Ticks
$script:trashFolder = Join-Path -Path . -ChildPath '.trash'
$script:trashFolder = Join-Path -Path $script:trashFolder -ChildPath $ticks.ToString('D19')
New-Item -Path $script:trashFolder -ItemType Directory | Out-Null
$script:trashFolder = Resolve-Path -Path $script:trashFolder
}