forked from pester/Pester
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.psake.ps1
55 lines (47 loc) · 1.54 KB
/
build.psake.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
$psake.use_exit_on_error = $true
properties {
$currentDir = resolve-path .
$Invocation = (Get-Variable MyInvocation -Scope 1).Value
$baseDir = $psake.build_script_dir
$version = git describe --abbrev=0 --tags
$nugetExe = "$baseDir\vendor\tools\nuget"
}
Task default -depends Build
Task Build -depends Test, Package
Task Package -depends Version-Module, Pack-Nuget, Unversion-Module
Task Release -depends Build, Push-Nuget
Task Test {
CD "$baseDir"
."$baseDir\bin\Pester.bat"
CD $currentDir
}
Task Version-Module{
$v = git describe --abbrev=0 --tags
$changeset=(git log -1 $($v + '..') --pretty=format:%H)
(Get-Content "$baseDir\Pester.psm1") `
| % {$_ -replace "\`$version\`$", "$version" } `
| % {$_ -replace "\`$sha\`$", "$changeset" } `
| Set-Content "$baseDir\Pester.psm1"
}
Task Unversion-Module{
$v = git describe --abbrev=0 --tags
$changeset=(git log -1 $($v + '..') --pretty=format:%H)
(Get-Content "$baseDir\Pester.psm1") `
| % {$_ -replace "$version", "`$version`$" } `
| % {$_ -replace "$changeset", "`$sha`$" } `
| Set-Content "$baseDir\Pester.psm1"
}
Task Pack-Nuget {
if (Test-Path "$baseDir\build") {
Remove-Item "$baseDir\build" -Recurse -Force
}
mkdir "$baseDir\build"
exec {
. $nugetExe pack "$baseDir\Pester.nuspec" -OutputDirectory "$baseDir\build" `
-NoPackageAnalysis -version $version
}
}
Task Push-Nuget {
$pkg = Get-Item -path $baseDir\build\Pester.1.*.*.nupkg
exec { .$nugetExe push $pkg.FullName }
}