-
Notifications
You must be signed in to change notification settings - Fork 3
/
Build.psake.ps1
45 lines (36 loc) · 1.19 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
$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 { & .\PSMock.Tests.ps1 }
# 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\PSMock.nuspec" -OutputDirectory "$baseDir\build" -NoPackageAnalysis -version $version
}
# update the version number in the file
Task Version-Module {
(Get-Content "$baseDir\PSMock.psm1") |
% {$_ -replace '\$version\$', "$version" } |
% {$_ -replace '\$changeset\$', "$changeset" } |
Set-Content "$baseDir\PSMock.psm1"
}
# clear out the version information in the file
Task Unversion-Module {
git checkout "$baseDir\PSMock.psm1"
}