-
Notifications
You must be signed in to change notification settings - Fork 5
/
Build.psake.ps1
60 lines (49 loc) · 1.49 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
55
56
57
58
59
60
$psake.use_exit_on_error = $true
#########################################
# to build a new version
# 1. git tag 1.0.x
# 2. build package
#########################################
properties {
$baseDir = $psake.build_script_dir
$version = git describe --abbrev=0 --tags
$changeset = (git log -1 $version --pretty=format:%H)
}
Task default -depends Test
Task Package -depends Test, Version-Module, Package-Nuget, Unversion-Module { }
# run tests
Task Test {
Import-Module .\PSate.psm1 -Force
Get-ChildItem tests -Filter "*.Tests.ps1" -Recurse:$Recurse |% {
try {
$scriptName = $_.FullName
& $_.FullName
Write-Host "PASS: $($_.FullName)"
}
catch {
Write-Host "FAIL: $scriptName"
throw $_
}
}
}
# package the nuget file
Task Package-Nuget {
# make sure there is a build directory
if (Test-Path "$baseDir\build") {
Remove-Item "$baseDir\build" -Recurse -Force
}
mkdir "$baseDir\build"
# pack it up
nuget pack "$baseDir\PSate.nuspec" -OutputDirectory "$baseDir\build" -NoPackageAnalysis -version $version
}
# update the version number in the file
Task Version-Module {
(Get-Content "$baseDir\PSate.psm1") |
% {$_ -replace '\$version\$', "$version" } |
% {$_ -replace '\$changeset\$', "$changeset" } |
Set-Content "$baseDir\PSate.psm1"
}
# clear out the version information in the file
Task Unversion-Module {
git checkout "$baseDir\PSate.psm1"
}